Part Number Hot Search : 
MA150 SST25VF0 LA1650 AD605BRZ 28221 PNZ313 ELECTRO S2907A
Product Description
Full Text Search
 

To Download T89C51AC2 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  rev. 4127d?8051?02/03 1 features  80c51 core architecture  256 bytes of on-chip ram  1 kb of on-chip xram  32 kb of on-chip flash memory ? data retention: 10 years at 85c read/write cycle: 10k  2 kb of on-chip flash for bootloader  2 kb of on-chip eeprom read/write cycle: 100k  14-sources 4-level interrupts  three 16-bit timers/counters  full duplex uart compatible 80c51  m a x im u m cry s tal f r e qu e ncy 40 mh z , in x2 m od e , 20 m h z (cpu c o r e , 20 m h z)  five ports: 32 + 2 digital i/o lines  five-channel 16-bit pca with: ? pwm (8-bit) ? high-speed output ? timer and edge capture  double data pointer  21-bit watchdog timer (7 programmable bits)  10-bit resolution analog to digital converter (adc) with 8 multiplexed inputs  on-chip emulation logic (enhanced hook system)  power saving modes: ? idle mode ? power-down mode  power supply: 3v to 5.5v  temperature range: industrial (-40 to +85 c)  packages: vqfp44, plcc44 description the T89C51AC2 is a high performance flash version of the 80c51 single chip 8-bit microcontrollers. it contains a 32 kb flash memory block for program and data. the 32 kb flash memory can be programmed either in parallel mode or in serial mode with the isp capability or with software. the programming voltage is internally generated from the standard vcc pin. the T89C51AC2 retains all features of the 80c51 with 256 bytes of internal ram, a 7- source 4-level interrupt controller and three timer/counters. in addition, the T89C51AC2 has a 10-bit a/d converter, a 2 kb boot flash memory, 2 kb eeprom for data, a programmable counter array, an xram of 1024 bytes, a hardware watch- dog timer, and a more versatile serial channel that facilitates multiprocessor communication (euart). the fully static design of the T89C51AC2 reduces system power consumption by bringing the clock frequency down to any value, even dc, without loss of data. the T89C51AC2 has two software-selectable modes of reduced activity and an 8-bit clock prescaler for further reduction in power consumption. in the idle mode the cpu is frozen while the peripherals and the interrupt system are still operating. in the power-down mode the ram is saved and all other functions are inoperative. the added features of the T89C51AC2 make it more powerful for applications that need a/d conversion, pulse width modulation, high speed i/o and counting capabili- ties such as industrial control, consumer goods, alarms, motor control, among others. while remaining fully compatible with the 80c52, the t8c51ac2 offers a superset of this standard microcontroller. in x2 mode, a maximum external clock rate of 20 mhz reaches a 300 ns cycle time. enhanced 8-bit microcontroller with 32 kb flash memory T89C51AC2
2 T89C51AC2 4127d ? 8051 ? 02/03 block diagram notes: 1. 8 analog inputs/8 digital i/o 2. 2-bit i/o port timer 0 int ram 256x8 t0 t1 rxd txd wr rd ea psen ale xtal2 xtal1 uart cpu timer 1 int1 ctrl int0 c51 core port 0 p0 port 1 port 2 port 3 parallel i/o ports and ext. bus p1 (1) p2 p3 xram 1kx8 ib-bus pca reset watch dog pca eci vss vcc timer 2 t2ex t2 port 4 p4 (2) 10 bit adc flash 32kx 8 boot loader 2kx8 ee prom 2kx8 var ef vavcc vagnd
3 T89C51AC2 4127d ? 8051 ? 02/03 pin configuration plcc44 p1.3/an3/cex0 p1.2/an2/eci p1.1/an1/t2ex p1.0/an 0/t2 varef vagnd reset vss vcc xtal1 xtal2 p3.7/rd p4.0 p4.1 p2.7/a15 p2.6/a14 p2.5/a13 p2.4/a12 p2.3/a11 p2.2/a10 p2.1/a9 p3.6/wr 39 38 37 36 35 34 33 32 29 30 31 7 8 9 10 11 12 13 14 17 16 15 18 19 20 21 22 23 24 25 26 27 28 6 5 4 3 2 44 43 42 41 40 ale psen p0.7/ad7 p0.6/ad6 p0.5/ad5 p0.2/ad2 p0.3/ad3 p0.4/ad4 p0.1/ad1 p0.0/ad0 p2.0/a8 p1.4/an4/cex1 p1.5/an5/cex2 p1.6/an6/cex3 p1.7/an7/cex4 ea p3.0/rxd p3.1/txd p3.2/int0 p3.3/int1 p3.4/t0 p3.5/t1 1 43 42 41 40 39 44 38 37 36 35 34 12 13 17 16 15 14 20 19 18 21 22 33 32 31 30 29 28 27 26 25 24 23 vqfp44 1 2 3 4 5 6 7 8 9 10 11 p1.4/an4/cex1 p1.5/an5/cex2 p1.6/an6/cex3 p1.7/an7/cex4 ea p3.0/rxd p3.1/txd p3.2/int0 p3.3/int1 p3.4/t0 p3.5/t1 ale psen p0.7/ad7 p0.6/ad6 p0.5/ad5 p0.2 /ad2 p0.3 /ad3 p0.4 /ad4 p0.1 /ad1 p0.0 /ad0 p2.0/a8 p1.3/an3/cex0 p1.2/an2/eci p1.1/an1/t2ex p1.0/an 0/t2 varef vagnd reset vss vcc xtal1 xtal2 p3.7/rd p4.0 p4.1 p2.7/a15 p2.6/a14 p2.5/a13 p2.4/a12 p2.3/a11 p2.2/a10 p2.1/a9 p3.6/wr
4 T89C51AC2 4127d ? 8051 ? 02/03 table 1. pin description pin name type description vss gnd circuit ground vcc supply voltage varef reference voltage for adc vagnd reference ground for adc p0.0:7 i/o port 0: is an 8-bit open drain bi-directional i/o port. port 0 pins that have 1 ? s written to them float, and in this state can be used as high-impedance inputs. port 0 is also the multiplexed low-order address and data bus during accesses to external program and data memory. in this application it uses strong internal pull-ups when emitting 1 ? s. port 0 also outputs the code bytes during program validation. external pull-ups are required during program verification. p1.0:7 i/o port 1: is an 8-bit bi-directional i/o port with internal pull-ups. port 1 pins can be used for digital input/output or as analog input s for the analog digital converter (adc). port 1 pins that have 1 ? s written to them are pulled high by the internal pull-up transistors and can be used as inputs in this state. as inputs, port 1 pins that are being pulled low externally will be the source of curr ent (i il , see section "electrical characteristic") because of the internal pull-ups. port 1 pins are assigned to be used as analog inputs via the adccf register (in this case the internal pull-ups are disconnected). as a secondary digital function, port 1 contains the timer 2 external trigger and clock input; the pca external clock input and the pca module i/o. p1.0/an0/t2 analog input channel 0, external clock input for timer/counter2. p1.1/an1/t2ex analog input channel 1, trigger input for timer/counter2. p1.2/an2/eci analog input channel 2, pca external clock input. p1.3/an3/cex0 analog input channel 3, pca module 0 entry of input/pwm output. p1.4/an4/cex1 analog input channel 4, pca module 1 entry of input/pwm output. p1.5/an5/cex2 analog input channel 5, pca module 2 entry of input/pwm output. p1.6/an6/cex3 analog input channel 6, pca module 3 entry of input/pwm output. p1.7/an7/cex4 analog input channel 7, pca module 4 entry ot input/pwm output. port 1 receives the low-order address byte during eprom programming and program verification. it can drive cmos inputs without external pull-ups. p2.0:7 i/o port 2: is an 8-bit bi-directional i/o port with internal pull-ups. port 2 pins that have 1 ? s written to them are pulled high by the internal pull-ups and can be used as inputs in this state. as inputs, port 2 pins that are being pulled low externally will be a source of current (i il , see section "electrical characteristic") because of the internal pull-ups. port 2 emits the high-order address byte during accesses to the external program memory and during accesses to external data memory that uses 16-bit addresses (movx @dptr). in this application, it uses strong internal pull-ups when emitting 1 ? s. during accesses to external data memory that use 8 bit addresses (movx @ri), port 2 transmits the contents of the p2 special function register. it also receives high-order addresses and control signals during program validation. it can drive cmos inputs without external pull-ups.
5 T89C51AC2 4127d ? 8051 ? 02/03 p3.0:7 i/o port 3: is an 8-bit bi-directional i/o port with internal pull-ups. port 3 pins that have 1 ? s written to them are pulled high by the internal pull-up transistors and can be used as inputs in this state. as inputs, port 3 pins that are being pulled low externally will b e a source of current (i il , see section "electrical characteristic") because of the internal pull-ups. the output latch corresponding to a secondary function must be programmed to one for that function to operate (except for txd and wr ). the secondary functions are assigned to the pins of port 3 as follows: p3.0/rxd: receiver data input (asynchronous) or data input/output (synchronous) of the serial interface p3.1/txd: transmitter data output (asynchronous) or clock output (synchronous) of the serial interface p3.2/int0 : external interrupt 0 input/timer 0 gate control input p3.3/int1 : external interrupt 1 input/timer 1 gate control input p3.4/t0: timer 0 counter input p3.5/t1: timer 1 counter input p3.6/wr : external data memory write strobe; latches the data byte from port 0 into the external data memory p3.7/rd : external data memory read strobe; enables the external data memory. it can drive cmos inputs without external pull-ups. p4.0:1 i/o port 4: is an 2-bit bi-directional i/o port with internal pull-ups. port 4 pins that have 1 ? s written to them are pulled high by the internal pull-ups and can be used as inputs in this state. as inputs, port 4 pins that are being pulled low externally will be a source of current (iil, on the datasheet) because of the internal pull-up transistor. p4.0 p4.1: it can drive cmos inputs without external pull-ups. reset i/o reset: a high level on this pin during two machine cycles while the oscillator is running resets the device. an internal pull-down resistor to vss permits power-on reset using only an external capacitor to vcc. ale o ale: an address latch enable output for latching the low byte of the address during accesses to the external memory. the ale is activated every 1/6 oscillator periods (1/3 in x2 mode) except during an external data memory access. when instructions are executed from an internal flash (ea = 1), ale generation can be disabled by the software. psen o psen : the program store enable output is a control signal that enables the external program memory of the bus during external fetch operations. it is activated twice each machine cycle during fetches from the external program memory. however, when executing from of the external program memory two activations of psen are skipped during each access to the external data memory. the psen is not activated for internal fetches. ea i ea : when external access is held at the high level, instructions are fetched from the internal flash when the program counter is less then 8000h. when held at the low level,T89C51AC2 fetches all instructions from the external program memory . xtal1 i xtal1: input of the inverting oscillator amplifier and input of the internal clock generator circuits. to drive the device from an external clock source, xtal1 should be driven, while xtal2 is left unconnected. to operate above a frequency of 16 mhz, a duty cycle of 50% should be maintained. xtal2 o xtal2: output from the inverting oscillator amplifier. table 1. pin description (continued) pin name type description
6 T89C51AC2 4127d ? 8051 ? 02/03 i/o configurations each port sfr operates via type-d latches, as illustrated in figure 1 for ports 3 and 4. a cpu "write to latch" signal initiates transfer of internal bus data into the type-d latch. a cpu "read latch" signal transfers the latched q output onto the internal bus. similarly, a "read pin" signal transfers the logical level of the port pin. some port data instructions activate the "read latch" signal while others activate the "read pin" signal. latch instruc- tions are referred to as read-modify-write instructions. each i/o line may be independently programmed as input or output. port 1, port 3 and port 4 figure 1 shows the structure of ports 1 and 3, which have internal pull-ups. an external source can pull the pin low. each port pin can be configured either for general-purpose i/o or for its alternate input output function. to use a pin for general-purpose output, set or clear the corresponding bit in the px reg- ister (x = 1,3 or 4). to use a pin for general-purpose input, set the bit in the px register. this turns off the output fet drive. to configure a pin for its alternate function, set the bit in the px register. when the latch is set, the "alternate output function" signal controls the output level (see figure 1). the operation of ports 1, 3 and 4 is discussed further in the "quasi-bidirectional port opera- tion" section. figure 1. port 1, port 3 and port 4 structure note: the internal pull-up can be disabled on p1 when analog function is selected. port 0 and port 2 ports 0 and 2 are used for general-purpose i/o or as the external address/data bus. port 0, shown in figure 3, differs from the other ports in not having internal pull-ups. figure 3 shows the structure of port 2. an external source can pull a port 2 pin low. to use a pin for general-purpose output, set or clear the corresponding bit in the px reg- ister (x = 0 or 2). to use a pin for general-purpose input, set the bit in the px register to turn off the output driver fet. d cl q p1.x latch internal write to latch read pin read latch p1.x p3.x p4.x alternate output function vcc internal pull-up (1) alternate input function p3.x p4.x bus
7 T89C51AC2 4127d ? 8051 ? 02/03 figure 2. port 0 structure notes: 1. port 0 is precluded from use as general-purpose i/o ports when used as address/data bus drivers. 2. port 0 internal strong pull-ups assist the logic-one output for memory bus cycles only. except for these bus cycles, the pull-up fet is off, port 0 outputs are open-drain. figure 3. port 2 structure notes: 1. port 2 is precluded from use as general-purpose i/o ports when as address/data bus drivers. 2. port 2 internal strong pull-ups fet (p1 in figure) assist the logic-one output for memory bus cycle. when port 0 and port 2 are used for an external memory cycle, an internal control signal switches the output-driver input from the latch output to the internal address/data line. read-modify-write instructions some instructions read the latch data rather than the pin data. the latch based instruc- tions read the data, modify the data and then rewrite the latch. these are called "read- modify-write" instructions. below is a complete list of these special instructions (see table ). when the destination operand is a port or a port bit, these instructions read the latch rather than the pin: d q p0.x latch internal write to latch read pin read latch 0 1 p0.x (1) address low/ data control vdd bus (2) d q p2.x latch internal write to latch read pin read latch 0 1 p2.x (1) address high/ control bus vdd internal pull-up (2)
8 T89C51AC2 4127d ? 8051 ? 02/03 it is not obvious the last three instructions in this list are read-modify-write instructions. these instructions read the port (all 8 bits), modify the specifically addressed bit and write the new byte back to the latch. these read-modify-write instructions are directed to the latch rather than the pin in order to avoid possible misinterpretation of voltage (and therefore, logic) levels at the pin. for example, a port bit used to drive the base of an external bipolar transistor can not rise above the transistor ? s base-emitter junction voltage (a value lower than vil). with a logic one written to the bit, attempts by the cpu to read the port at the pin are misinterpreted as logic zero. a read of the latch rather than the pins returns the correct logic-one value. quasi-bidirectional port operation port 1, port 2, port 3 and port 4 have fixed internal pull-ups and are referred to as "quasi-bidirectional" ports. when configured as an input, the pin impedance appears as logic one and sources current in response to an external logic zero condition. port 0 is a "true bidirectional" pin. the pins float when configured as input. resets write logic one to all port latches. if logical zero is subsequently written to a port latch, it can be returned to input conditions by a logical one written to the latch. note: port latch values change near the end of read-modify-write instruction cycles. output buffers (and therefore the pin state) update early in the instruction after read-modify- write instruction cycle. logical zero-to-one transitions in port 1, port 2, port 3 and port 4 use an additional pull- up (p1) to aid this logic transition (see figure 4.). this increases switch speed. this extra pull-up sources 100 times normal internal circuit current during 2 oscillator clock periods. the internal pull-ups are field-effect transistors rather than linear resistors. pull- ups consist of three p-channel fet (pfet) devices. a pfet is on when the gate senses logical zero and off when the gate senses logical one. pfet #1 is turned on for two oscillator periods immediately after a zero-to-one transition in the port latch. a logical one at the port pin turns on pfet #3 (a weak pull-up) through the inverter. this inverter and pfet pair form a latch to drive logical one. pfet #2 is a very weak pull-up switched on whenever the associated nfet is switched off. this is traditional cmos switch con- vention. current strengths are 1/10 that of pfet #3. table 2. read-modify-write instructions instruction description example anl logical and anl p1, a orl logical or orl p2, a xrl logical ex-or xrl p3, a jbc jump if bit = 1 and clear bit jbc p1.1, label cpl complement bit cpl p3.0 inc increment inc p2 dec decrement dec p2 djnz decrement and jump if not zero djnz p3, label mov px.y, c move carry bit to bit y of port x mov p1.5, c clr px.y clear bit y of port x clr p2.4 set px.y set bit y of port x set p3.3
9 T89C51AC2 4127d ? 8051 ? 02/03 figure 4. internal pull-up configurations note: port 2 p1 assists the logic-one output for memory bus cycles. read pin input data p1.x output data 2 osc. periods n p1(1) p2 p3 vcc vcc vcc p2.x p3.x p4.x
10 T89C51AC2 4127d ? 8051 ? 02/03 sfr mapping the special function registers (sfrs) of the T89C51AC2 fall into the following categories: table 3. c51 core sfrs mnemonicaddname 76543210 acc e0h accumulator ???????? b f0h b register ???????? psw d0h program status word cy ac f0 rs1 rs0 ov f1 p sp 81h stack pointer ???????? dpl 82h data pointer low byte lsb of dptr ???????? dph 83h data pointer high byte msb of dptr ???????? table 4. i/o port sfrs mnemonicaddname 76543210 p0 80h port 0 ???????? p1 90h port 1 ???????? p2 a0h port 2 ???????? p3 b0h port 3 ???????? p4 c0h port 4 (x2) ???????? table 5. timers sfrs mnemonicaddname 76543210 th0 8ch timer/counter 0 high byte ???????? tl0 8ah timer/counter 0 low byte ???????? th1 8dh timer/counter 1 high byte ???????? tl1 8bh timer/counter 1 low byte ???????? th2 cdh timer/counter 2 high byte ???????? tl2 cch timer/counter 2 low byte ???????? tcon 88h timer/counter 0 and 1 control tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 tmod 89h timer/counter 0 and 1 modes gate1 c/t1# m11 m01 gate0 c/t0# m10 m00
11 T89C51AC2 4127d ? 8051 ? 02/03 t2con c8h timer/counter 2 control tf2 exf2 rclk tclk exen2 tr2 c/t2# cp/rl2# t2mod c9h timer/counter 2 mode ?????? t2oe dcen rcap2h cbh timer/counter 2 reload/capture high byte ???????? rcap2l cah timer/counter 2 reload/capture low byte ???????? wdtrst a6h watchdog timer reset ???????? wdtprg a7h watchdog timer program ????? s2 s1 s0 table 5. timers sfrs (continued) mnemonicaddname 76543210 table 6. serial i/o port sfrs mnemonicaddname 76543210 scon 98h serial control fe/sm0 sm1 sm2 ren tb8 rb8 ti ri sbuf 99h serial data buffer ???????? saden b9h slave address mask ???????? saddr a9h slave address ???????? table 7. pca sfrs mnemonic addname 76543210 ccon d8h pca timer/counter control cf cr ? ccf4 ccf3 ccf2 ccf1 ccf0 cmod d9h pca timer/counter mode cidl wdte ??? cps1 cps0 ecf cl e9h pca timer/counter low byte ???????? ch f9h pca timer/counter high byte ???????? ccapm0 ccapm1 ccapm2 ccapm3 ccapm4 dah dbh dch ddh deh pca timer/counter mode 0 pca timer/counter mode 1 pca timer/counter mode 2 pca timer/counter mode 3 pca timer/counter mode 4 ? ecom0 ecom1 ecom2 ecom3 ecom4 capp0 capp1 capp2 capp3 capp4 capn0 capn1 capn2 capn3 capn4 mat0 mat1 mat2 mat3 mat4 tog0 tog1 tog2 tog3 tog4 pwm0 pwm1 pwm2 pwm3 pwm4 eccf0 eccf1 eccf2 eccf3 eccf4 ccap0h ccap1h ccap2h ccap3h ccap4h fah fbh fch fdh feh pca compare capture module 0 h pca compare capture module 1 h pca compare capture module 2 h pca compare capture module 3 h pca compare capture module 4 h ccap0h7 ccap1h7 ccap2h7 ccap3h7 ccap4h7 ccap0h6 ccap1h6 ccap2h6 ccap3h6 ccap4h6 ccap0h5 ccap1h5 ccap2h5 ccap3h5 ccap4h5 ccap0h4 ccap1h4 ccap2h4 ccap3h4 ccap4h4 ccap0h3 ccap1h3 ccap2h3 ccap3h3 ccap4h3 ccap0h2 ccap1h2 ccap2h2 ccap3h2 ccap4h2 ccap0h1 ccap1h1 ccap2h1 ccap3h1 ccap4h1 ccap0h0 ccap1h0 ccap2h0 ccap3h0 ccap4h0
12 T89C51AC2 4127d ? 8051 ? 02/03 ccap0l ccap1l ccap2l ccap3l ccap4l eah ebh ech edh eeh pca compare capture module 0 l pca compare capture module 1 l pca compare capture module 2 l pca compare capture module 3 l pca compare capture module 4 l ccap0l7 ccap1l7 ccap2l7 ccap3l7 ccap4l7 ccap0l6 ccap1l6 ccap2l6 ccap3l6 ccap4l6 ccap0l5 ccap1l5 ccap2l5 ccap3l5 ccap4l5 ccap0l4 ccap1l4 ccap2l4 ccap3l4 ccap4l4 ccap0l3 ccap1l3 ccap2l3 ccap3l3 ccap4l3 ccap0l2 ccap1l2 ccap2l2 ccap3l2 ccap4l2 ccap0l1 ccap1l1 ccap2l1 ccap3l1 ccap4l1 ccap0l0 ccap1l0 ccap2l0 ccap3l0 ccap4l0 table 7. pca sfrs (continued) mnemonic addname 76543210 table 8. interrupt sfrs mnemonicaddname 76543210 ien0 a8h interrupt enable control 0 ea ec et2 es et1 ex1 et0 ex0 ien1 e8h interrupt enable control 1 ?????? eadc ? ipl0 b8h interrupt priority control low 0 ? ppc pt2 ps pt1 px1 pt0 px0 iph0 b7h interrupt priority control high 0 ? ppch pt2h psh pt1h px1h pt0h px0h ipl1 f8h interrupt priority control low 1 ?????? padcl ? iph1 f7h interrupt priority control high1 ?????? padch ? table 9. adc sfrs mnemonicaddname 76543210 adcon f3h adc control ? psidle aden adeoc adsst sch2 sch1 sch0 adcf f6h adc configuration ch7 ch6 ch5 ch4 ch3 ch2 ch1 ch0 adclk f2h adc clock ??? prs4 prs3 prs2 prs1 prs0 addh f5h adc data high byte adat9 adat8 adat7 adat6 adat5 adat4 adat3 adat2 addl f4h adc data low byte ?????? adat1 adat0 table 10. other sfrs mnemonicaddname 76543210 pcon 87h power control smod1 smod0 ? pof gf1 gf0 pd idl auxr 8eh auxiliary register 0 ?? m0 ? xrs1 xrs2 extram a0 auxr1 a2h auxiliary register 1 ?? enboot ? gf3 0 ? dps ckcon 8fh clock control ? wdx2 pcax2 six2 t2x2 t1x2 t0x2 x2 fcon d1h flash control fpl3 fpl2 fpl1 fpl0 fps fmod1 fmod0 fbusy eecon d2h eeprom contol eepl3 eepl2 eepl1 eepl0 ?? eee eebusy
13 T89C51AC2 4127d ? 8051 ? 02/03 reserved note: 1. these registers are bit ? addressable. sixteen addresses in the sfr space are both byte ? addressable and bit ? addressable. the bit ? addressable sfr ? s are those whose address ends in 0 and 8. the bit addresses, in this area, are 0x80 through to 0xff. table 11. sfr mapping 0/8 (1) 1/9 2/a 3/b 4/c 5/d 6/e 7/f f8h ipl1 xxxx xx0x ch 0000 0000 ccap0h 0000 0000 ccap1h 0000 0000 ccap2h 0000 0000 ccap3h 0000 0000 ccap4h 0000 0000 ffh f0h b 0000 0000 adclk xxx0 0000 adcon x000 0000 addl 0000 0000 addh 0000 0000 adcf 0000 0000 iph1 xxxx xx0x f7h e8h ien1 xxxx xx0x cl 0000 0000 ccap0l 0000 0000 ccap1l 0000 0000 ccap2l 0000 0000 ccap3l 0000 0000 ccap4l 0000 0000 efh e0h acc 0000 0000 e7h d8h ccon 00x0 0000 cmod 00xx x000 ccapm0 x000 0000 ccapm1 x000 0000 ccapm2 x000 0000 ccapm3 x000 0000 ccapm4 x000 0000 dfh d0h psw 0000 0000 fcon 0000 0000 eecon xxxx xx00 d7h c8h t2con 0000 0000 t2mod xxxx xx00 rcap2l 0000 0000 rcap2h 0000 0000 tl2 0000 0000 th2 0000 0000 cfh c0h p4 xxxx xx11 c7h b8h ipl0 x000 0000 saden 0000 0000 bfh b0h p3 1111 1111 iph0 x000 0000 b7h a8h ien0 0000 0000 saddr 0000 0000 afh a0h p2 1111 1111 auxr1 xxxx 00x0 wdtrst 1111 1111 wdtprg xxxx x000 a7h 98h scon 0000 0000 sbuf 0000 0000 9fh 90h p1 1111 1111 97h 88h tcon 0000 0000 tmod 0000 0000 tl0 0000 0000 tl1 0000 0000 th0 0000 0000 th1 0000 0000 auxr x00x 1100 ckcon 0000 0000 8fh 80h p0 1111 1111 sp 0000 0111 dpl 0000 0000 dph 0000 0000 pcon 00x1 0000 87h 0/8 (1) 1/9 2/a 3/b 4/c 5/d 6/e 7/f
14 T89C51AC2 4127d ? 8051 ? 02/03 clock the T89C51AC2 core needs only 6 clock periods per machine cycle. this feature, called ? x2 ? , provides the following advantages:  divides frequency crystals by 2 (cheaper crystals) while keeping the same cpu power.  saves power consumption while keeping the same cpu power (oscillator power saving).  saves power consumption by dividing dynamic operating frequency by 2 in operating and idle modes.  increases cpu power by 2 while keeping the same crystal frequency. in order to keep the original c51 compatibility, a divider-by-2 is inserted between the xtal1 signal and the main clock input of the core (phase generator). this divider may be disabled by the software. an extra feature is available to start after reset in the x2 mode. this feature can be enabled by a bit x2b in the hardware security byte. this bit is described in the section "in-system-programming". description the x2 bit in the ckcon register (see table 12) allows switching from 12 clock cycles per instruction to 6 clock cycles and vice versa. at reset, the standard speed is activated (std mode). setting this bit activates the x2 feature (x2 mode) for the cpu clock only (see figure 5.). the timers 0, 1 and 2, uart, pca, or watchdog switch in x2 mode only if the corre- sponding bit is cleared in the ckcon register. the clock for the whole circuit and peripheral is first divided by two before being used by the cpu core and peripherals. this allows any cyclic ratio to be accepted on the xtal1 input. in x2 mode, as this divider is bypassed, the signals on xtal1 must have a cyclic ratio between 40 to 60%. figure 5. shows the clock generation block diagram. the x2 bit is validated on the xtal1 2 rising edge to avoid glitches when switching from the x2 to the std mode. figure 6 shows the mode switching waveforms.
15 T89C51AC2 4127d ? 8051 ? 02/03 figure 5. clock cpu generation diagram xtal1 xtal2 pd pcon.1 cpu core 1 0 2 periph clock clock peripheral clock symbol cpu clock cpu core clock symbol x2 ckcon.0 x2b hardware byte wdx2 ckcon.6 pcax2 ckcon.5 six2 ckcon.4 t2x2 ckcon.3 t1x2 ckcon.2 t0x2 ckcon.1 idl pcon.0 1 0 2 1 0 2 1 0 2 1 0 2 1 0 2 1 0 2 x2 ckcon.0 fwd clock fpca clock fuart clock ft2 clock ft1 clock ft0 clock and adc on reset
16 T89C51AC2 4127d ? 8051 ? 02/03 figure 6. mode switching waveforms note: in order to prevent any incorrect operation while operating in the x2 mode, users must be aware that all peripherals using the clock frequency as a time reference (uart, timers...) will have their time reference divided by two. for example a free running timer generating an interrupt every 20 ms will then generate an interrupt every 10 ms. a uart with a 4800 baud rate will have a 9600 baud rate. xtal2 cpu x2 bit x2 mode std mode std mode
17 T89C51AC2 4127d ? 8051 ? 02/03 register table 12. ckcon register ckcon (s:8fh) clock control register note: 1. this control bit is validated when the cpu clock bit x2 is set; when x2 is low, this bit has no effect. reset value = x000 0000b 76543210 - wdx2 pcax2 six2 t2x2 t1x2 t0x2 x2 bit number bit mnemonic description -- reserved do not set this bit. 6wdx2 watchdog clock (1) clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 5pcax2 programmable counter array clock (1) clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 4six2 enhanced uart clock (mode 0 and 2) (1) clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 3t2x2 timer 2 clock (1) clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 2t1x2 timer 1 clock (1) clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 1t0x2 timer 0 clock (1) clear to select 6 clock periods per peripheral clock cycle. set to select 12 clock periods per peripheral clock cycle. 0x2 cpu clock clear to select 12 clock periods per machine cycle (std mode) for cpu and all the peripherals. set to select 6 clock periods per machine cycle (x2 mode) and to enable the individual peripherals "x2"bits.
18 T89C51AC2 4127d ? 8051 ? 02/03 power management two power reduction modes are implemented in the T89C51AC2: the idle mode and the power-down mode. these modes are detailed in the following sections. in addition to these power reduction modes, the clocks of the core and peripherals can be dynamically divided by 2 using the x2 mode detailed in section ? clock ? . reset pin in order to start-up (cold reset) or to restart (warm reset) properly the microcontroller, a high level has to be applied on the rst pin. a bad level leads to a wrong initialisation of the internal registers like sfrs, pc, etc. and to unpredictable behavior of the microcon- troller. a warm reset can be applied either directly on the rst pin or indirectly by an internal reset source such as a watchdog, pca, timer, etc. at power-up (cold reset) two conditions are required before enabling a cpu start-up:  vdd must reach the specified vdd range,  the level on xtal1 input must be outside the specification (vih, vil). if one of these two conditions are not met, the microcontroller does not start correctly and can execute an instruction fetch from anywhere in the program space. an active level applied on the rst pin must be maintained until both of the above conditions are met. a reset is active when the level vih1 is reached and when the pulse width covers the period of time where vdd and the oscillator are not stabilized. two parameters have to be taken into account to determine the reset pulse width:  vdd rise time (vddrst),  oscillator startup time (oscrst). to determine the capacitor the highest value of these two parameters has to be chosen. the reset circuitry is shown in figure 7. figure 7. reset circuitry table 13 and table 14 give some typical examples for three values of vdd rise times, two values of oscillator start-up time and two pull-down resistor values. table 13. minimum reset capacitor for a 15k pull-down resistor note: these values assume vdd starts from 0v to the nominal value. if the time between two on/off sequences is too fast, the power-supply decoupling capacitors may not be fully discharged, leading to a bad reset sequence. oscrst/vddrst 1ms 10ms 100ms 5 ms 2.7 f 4.7 f 47 f 20 ms 10 f 15 f 47 f 0 vdd rrst crst rst pin internal reset reset input circuitry
19 T89C51AC2 4127d ? 8051 ? 02/03 warm reset to achieve a valid reset, the reset signal must be maintained for at least 2 machine cycles (24 oscillator clock periods) while the oscillator is running. the number of clock periods is mode independent (x2 or x1). watchdog reset as detailed in section ? pca watchdog timer ? , page 77, the wdt generates a 96-clock period pulse on the rst pin. in order to properly propagate this pulse to the rest of the application in case of external capacitor or power-supply supervisor circuit, a 1k ? resis- tor must be added as shown figure 8. figure 8. reset circuitry for wdt reset out usage reset recommendation to prevent flash corruption an example of bad initialization situation may occur in an instance where the bit enboot in auxr1 register is initialized from the hardware bit bljb upon reset. since this bit allows mapping of the bootloader in the code area, a reset failure can be critical. if one wants the enboot cleared in order to unmap the boot from the code area (yet due to a bad reset) the bit enboot in sfrs may be set. if the value of program counter is accidently in the range of the boot memory addresses then a flash access (write or erase) may corrupt the flash on-chip memory. it is recommended to use an external reset circuitry featuring power supply monitoring to prevent system malfunction during periods of insufficient power supply voltage (power supply failure, power supply switched off). idle mode idle mode is a power reduction mode that reduces the power consumption. in this mode, program execution halts. idle mode freezes the clock to the cpu at known states while the peripherals continue to be clocked. the cpu status before entering idle mode is preserved, i.e., the program counter and program status word register retain their data for the duration of idle mode. the contents of the sfrs and ram are also retained. the status of the port pins during idle mode is detailed in table 13. entering idle mode to enter idle mode, you must set the idl bit in pcon register (see table 14). the t89c51cc02 enters idle mode upon execution of the instruction that sets idl bit. the instruction that sets idl bit is the last instruction executed. note: if idl bit and pd bit are set simultaneously, the t89c51cc02 enters power-down mode. then it does not go in idle mode when exiting power-down mode. exiting idle mode there are two ways to exit idle mode: 1. generate an enabled interrupt. ? hardware clears idl bit in pcon register which restores the clock to the cpu. execution resumes with the interrupt service routine. upon completion of the interrupt service routine, program execution resumes with the instruction immediately following the instruction that activated idle mode. r rst rst vss to cpu core and peripherals vdd + vss vdd rst 1k to other on-board circuitry
20 T89C51AC2 4127d ? 8051 ? 02/03 the general-purpose flags (gf1 and gf0 in pcon register) may be used to indicate whether an interrupt occurred during normal operation or during idle mode. when idle mode is exited by an interrupt, the interrupt service routine may examine gf1 and gf0. 2. generate a reset. ? a logic high on the rst pin clears idl bit in pcon register directly and asynchronously. this restores the clock to the cpu. program execution momentarily resumes with the instruction immediately following the instruction that activated the idle mode and may continue for a number of clock cycles before the internal reset algorithm takes control. reset initializes the t89c51cc02 and vectors the cpu to address c:0000h. notes: 1. during the time that execution resumes, the internal ram cannot be accessed; how- ever, it is possible for the port pins to be accessed. to avoid unexpected outputs at the port pins, the instruction immediately following the instruction that activated idle mode should not write to a port pin or to the external ram. 2. if idle mode is invoked by adc idle, the adc conversion completion will exit idle. power-down mode the power-down mode places the t89c51cc02 in a very low power state. power-down mode stops the oscillator and freezes all clocks at known states. the cpu status prior to entering power-down mode is preserved, i.e., the program counter, program status word register retain their data for the duration of power-down mode. in addition, the sfrs and ram contents are preserved. the status of the port pins during power-down mode is detailed in table 13. entering power-down mode to enter power-down mode, set pd bit in pcon register. the t89c51cc02 enters the power-down mode upon execution of the instruction that sets pd bit. the instruction that sets pd bit is the last instruction executed. exiting power-down mode if vdd was reduced during the power-down mode, do not exit power-down mode until vdd is restored to the normal operating level. there are two ways to exit the power-down mode: 1. generate an enabled external interrupt. ? the t89c51cc02 provides capability to exit from power-down using int0#, int1#. hardware clears pd bit in pcon register which starts the oscillator and restores the clocks to the cpu and peripherals. using intx# input, execution resumes when the input is released (see figure 9) while using kinx input, execution resumes after counting 1024 clock ensuring the oscillator is restarted properly (see figure 8). execution resumes with the interrupt service routine. upon completion of the interrupt service routine, program execution resumes with the instruction immediately following the instruction that activated power-down mode. note: 1. the external interrupt used to exit power-down mode must be configured as level sensitive (int0# and int1#) and must be assigned the highest priority. in addition, the duration of the interrupt must be long enough to allow the oscillator to stabilize. the execution will only resume when the interrupt is deasserted. 2. exit from power-down by external interrupt does not affect the sfrs nor the internal ram content.
21 T89C51AC2 4127d ? 8051 ? 02/03 figure 9. power-down exit waveform using int1:0# 2. generate a reset. ? a logic high on the rst pin clears pd bit in pcon register directly and asynchronously. this starts the oscillator and restores the clock to the cpu and peripherals. program execution momentarily resumes with the instruction immediately following the instruction that activated power-down mode and may continue for a number of clock cycles before the internal reset algorithm takes control. reset initializes the t89c51cc02 and vectors the cpu to address 0000h. notes: 1. during the time that execution resumes, the internal ram cannot be accessed; how- ever, it is possible for the port pins to be accessed. to avoid unexpected outputs at the port pins, the instruction immediately following the instruction that activated the power-down mode should not write to a port pin or to the external ram. 2. exit from power-down by reset redefines all the sfrs, but does not affect the internal ram content. int1:0# osc power-down phase oscillator restart phase active phase active phase
22 T89C51AC2 4127d ? 8051 ? 02/03 registers table 14. pcon register pcon (s:87h) ? power configuration register reset value = 00x1 0000b 76543210 smod1 smod0 - pof gf1 gf0 pd idl bit number bit mnemonic description 7smod1 serial port mode bit 1 set to select double baud rate in mode 1, 2 or 3 6smod0 serial port mode bit 0 clear to select sm0 bit in scon register. set to select fe bit in scon register. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4pof power-off flag clear to recognize next reset type. set by hardware when v cc rises from 0 to its nominal voltage. can also be set by software. 3gf1 general-purpose flag 1 one use is to indicate whether an interrupt occurred during normal operation or during idle mode. 2gf0 general-purpose flag 0 one use is to indicate whether an interrupt occurred during normal operation or during idle mode. 1pd power-down mode bit cleared by hardware when an interrupt or reset occurs. set to activate the power-down mode. if idl and pd are both set, pd takes precedence. 0idl idle mode bit cleared by hardware when an interrupt or reset occurs. set to activate the idle mode. if idl and pd are both set, pd takes precedence.
23 T89C51AC2 4127d ? 8051 ? 02/03 data memory the T89C51AC2 provides data memory access in two different spaces: 1. the internal space mapped in three separate segments:  the lower 128 bytes ram segment.  the upper 128 bytes ram segment.  the expanded 1024 bytes ram segment (xram). 2. the external space. a fourth internal segment is available but dedicated to special function registers, sfrs, (addresses 80h to ffh) accessible by direct addressing mode. figure 11 shows the internal and external data memory spaces organization. figure 10. internal memory - ram figure 11. internal and external data memory organization xram-xram upper 128 bytes internal ram lower 128 bytes internal ram special function registers 80h 80h 00h ffh ffh direct addressing addressing 7fh direct or indirect indirect addressing 256 up to 1024 bytes 00h 64 kb external xram 0000h ffffh internal xram extram = 0 extram = 1 ffh or 3ffh internal external
24 T89C51AC2 4127d ? 8051 ? 02/03 internal space lower 128 bytes ram the lower 128 bytes of ram (see figure 11) are accessible from address 00h to 7fh using direct or indirect addressing modes. the lowest 32 bytes are grouped into 4 banks of 8 registers (r0 to r7). two bits rs0 and rs1 in psw register (see figure 17) select which bank is in use according to table 15. this allows more efficient use of code space, since register instructions are shorter than instructions that use direct address- ing, and can be used for context switching in interrupt service routines. table 15. register bank selection the next 16 bytes above the register banks form a block of bit-addressable memory space. the c51 instruction set includes a wide selection of single-bit instructions, and the 128 bits in this area can be directly addressed by these instructions. the bit addresses in this area are 00h to 7fh. figure 12. lower 128 bytes internal ram organization upper 128 bytes ram the upper 128 bytes of ram are accessible from address 80h to ffh using only indirect addressing mode. expanded ram the on-chip 1024 bytes of expanded ram (xram) are accessible from address 0000h to 03ffh using indirect addressing mode through movx instructions. in this address range, the bit extram in auxr register is used to select the xram (default) or the xram. as shown in figure 11 when extram = 0, the xram is selected and when extram = 1, the xram is selected. the size of xram can be configured by xrs1-0 bit in auxr register (default size is 1024 bytes). note: lower 128 bytes ram, upper 128 bytes ram, and expanded ram are made of volatile memory cells. this means that the ram content is indeterminate after power-up and must then be initialized properly. rs1 rs0 description 0 0 register bank 0 from 00h to 07h 0 1 register bank 0 from 08h to 0fh 1 0 register bank 0 from 10h to 17h 1 1 register bank 0 from 18h to 1fh bit-addressable space 4 banks of 8 registers r0-r7 30h 7fh (bit addresses 0-7fh) 20h 2fh 18h 1fh 10h 17h 08h 0fh 00h 07h
25 T89C51AC2 4127d ? 8051 ? 02/03 external space memory interface the external memory interface comprises the external bus (port 0 and port 2) as well as the bus control signals (rd , wr , and ale). figure 13 shows the structure of the external address bus. p0 carries address a7:0 while p2 carries address a15:8. data d7:0 is multiplexed with a7:0 on p0. table 16 describes the external memory interface signals. figure 13. external data memory interface structure table 16. external data memory interface signals external bus cycles this section describes the bus cycles the T89C51AC2 executes to read (see figure 14), and write data (see figure 15) in the external data memory. external memory cycle takes 6 cpu clock periods. this is equivalent to 12 oscillator clock period in standard mode or 6 oscillator clock periods in x2 mode. for further infor- mation on x2 mode. slow peripherals can be accessed by stretching the read and write cycles. this is done using the m0 bit in auxr register. setting this bit changes the width of the rd and wr signals from 3 to 15 cpu clock periods. for simplicity, the accompanying figures depict the bus cycle waveforms in idealized form and do not provide precise timing information. for bus cycle timing parameters refer to the section ? ac characteristics ? . signal name type description alternative function a15:8 o address lines upper address lines for the external bus. p2.7:0 ad7:0 i/o address/data lines multiplexed lower address lines and data for the external memory. p0.7:0 ale o address latch enable ale signals indicates that valid address information are available on lines ad7:0. - rd o read read signal output to external data memory. p3.7 wr o write write signal output to external memory. p3.6 ram peripheral T89C51AC2 p2 p0 ad7:0 a15:8 a7:0 a15:8 d7:0 a7:0 ale wr oe rd wr latch
26 T89C51AC2 4127d ? 8051 ? 02/03 figure 14. external data read waveforms notes: 1. rd signal may be stretched using m0 bit in auxr register. 2. when executing movx @ri instruction, p2 outputs sfr content. figure 15. external data write waveforms notes: 1. wr signal may be stretched using m0 bit in auxr register. 2. when executing movx @ri instruction, p2 outputs sfr content. ale p0 p2 rd 1 dpl or ri d7:0 dph or p22 p2 cpu clock ale p0 p2 wr 1 dpl or ri d7:0 p2 cpu clock dph or p22
27 T89C51AC2 4127d ? 8051 ? 02/03 dual data pointer description the T89C51AC2 implements a second data pointer for speeding up code execution and reducing code size in case of intensive usage of external memory accesses. dptr 0 and dptr 1 are seen by the cpu as dptr and are accessed using the sfr addresses 83h and 84h that are the dph and dpl addresses. the dps bit in auxr1 register (see figure 19) is used to select whether dptr is the data pointer 0 or the data pointer 1 (see figure 16). figure 16. dual data pointer implementation application software can take advantage of the additional data pointers to both increase speed and reduce code size, for example, block operations (copy, compare ? ) are well served by using one data pointer as a ? source ? pointer and the other one as a ? destination ? pointer. hereafter is an example of block move implementation using the two pointers and coded in assembler. the latest c compiler takes also advantage of this feature by providing enhanced algorithm libraries. the inc instruction is a short (2 bytes) and fast (6 machine cycle) way to manipulate the dps bit in the auxr1 register. however, note that the inc instruction does not directly force the dps bit to a particular state, but simply toggles it. in simple routines, such as the block move example, only the fact that dps is toggled in the proper sequence mat- ters, not its actual value. in other words, the block move routine works the same whether dps is '0' or '1' on entry. ; ascii block move using dual data pointers ; modifies dptr0, dptr1, a and psw ; ends when encountering null character ; note: dps exits opposite to the entry state unless an extra inc auxr1 is added auxr1equ0a2h move:movdptr,#source ; address of source incauxr1 ; switch data pointers movdptr,#dest ; address of dest mv_loop:incauxr1; switch data pointers movxa,@dptr; get a byte from source incdptr; increment source address incauxr1; switch data pointers movx@dptr,a; write the byte to dest incdptr; increment dest address jnzmv_loop; check for null terminator end_move: 0 1 dph0 dph1 dpl0 0 1 dps auxr1.0 dph dpl dpl1 dptr dptr0 dptr1
28 T89C51AC2 4127d ? 8051 ? 02/03 registers table 17. psw register psw (s:d0h) program status word register reset value = 0000 0000b table 18. auxr register auxr (s:8eh) auxiliary register 76543210 cy ac f0 rs1 rs0 ov f1 p bit number bit mnemonic description 7cy carry flag carry out from bit 1 of alu operands. 6ac auxiliary carry flag carry out from bit 1 of addition operands. 5f0 user definable flag 0. 4-3 rs1:0 register bank select bits refer to table 15 for bits description. 2ov overflow flag overflow set by arithmetic operations. 1f1 user definable flag 1 0p parity bit set when acc contains an odd number of 1 ? s. cleared when acc contains an even number of 1 ? s. 76543210 - - m0 - xrs1 xrs0 extram a0 bit number bit mnemonic description 7-6 - reserved the value read from these bits are indeterminate. do not set this bit. 5m0 stretch movx control: the rd/ and the wr/ pulse length is increased according to the value of m0. m0 pulse length in clock period 0 6 1 30 4- reserved the value read from this bit is indeterminate. do not set this bit. 3-2 xrs1-0 xram size: accessible size of the xram xrs 1:0 xram size 0 0 256 bytes 0 1 512 bytes 1 0 768 bytes 1 1 1024 bytes (default)
29 T89C51AC2 4127d ? 8051 ? 02/03 reset value = x00x 1100b not bit addressable table 19. auxr1 register auxr1 (s:a2h) auxiliary control register 1 reset value = xxxx 00x0b note: 1. enboot is initialized with the invert bljb at reset. see in-system programming section. 1extram internal/external ram (00h - ffh) access using movx @ ri/@ dptr 0 - internal xram access using movx @ ri/@ dptr. 1 - external data memory access. 0a0 disable/enable ale) 0 - ale is emitted at a constant rate of 1/6 the oscillator frequency (or 1/3 if x2 mode is used) 1 - ale is active only during a movx or movc instruction. 76543210 - - enboot - gf3 0 - dps bit number bit mnemonic description 7-6 - reserved the value read from these bits is indeterminate. do not set these bits. 5enboot (1) enable boot flash set this bit for map the boot flash between f800h -ffffh clear this bit for disable boot flash. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3gf3 general-purpose flag 3 20 always zero this bit is stuck to logic 0 to allow inc auxr1 instruction without affecting gf3 flag. 1- reserved for data pointer extension. 0dps data pointer select bit set to select second dual data pointer: dptr1. clear to select first dual data pointer: dptr0. bit number bit mnemonic description
30 T89C51AC2 4127d ? 8051 ? 02/03 eeprom data memory the 2 kb on-chip eeprom memory block is located at addresses 0000h to 07ffh of the xram/xram memory space and is selected by setting control bits in the eecon register. a read in the eeprom memory is done with a movx instruction. a physical write in the eeprom memory is done in two steps: write data in the column latches and transfer of all data latches into an eeprom memory row (programming). the number of data written on the page may vary from 1 up to 128 bytes (the page size). when programming, only the data written in the column latch is programmed and a ninth bit is used to obtain this feature. this provides the capability to program the whole memory by bytes, by page or by a number of bytes in a page. indeed, each ninth bit is set when the writing the corresponding byte in a row and all these ninth bits are reset after the writing of the complete eeprom row. write data in the column latches data is written by byte to the column latches as for an external ram memory. out of the 11 address bits of the data pointer, the 4 msbs are used for page selection (row) and 7 are used for byte selection. between two eeprom programming sessions, all the addresses in the column latches must stay on the same page, meaning that the 4 msb must no be changed. the following procedure is used to write to the column latches:  save and disable interrupt.  set bit eee of eecon register  load dptr with the address to write  store a register with the data to be written  execute a movx @dptr, a  if needed loop the three last instructions until the end of a 128 bytes page  restore interrupt. note: the last page address used when loading the column latch is the one used to select the page programming address. programming the eeprom programming consists of the following actions:  writing one or more bytes of one page in the column latches. normally, all bytes must belong to the same page; if not, the last page address will be latched and the others discarded.  launching programming by writing the control sequence (50h followed by a0h) to the eecon register.  eebusy flag in eecon is then set by hardware to indicate that programming is in progress and that the eeprom segment is not available for reading.  the end of programming is indicated by a hardware clear of the eebusy flag. note: the sequence 5xh and axh must be executed without instructions between then other- wise the programming is aborted. read data the following procedure is used to read the data stored in the eeprom memory:  save and disable interrupt  set bit eee of eecon register  load dptr with the address to read  execute a movx a, @dptr  restore interrupt
31 T89C51AC2 4127d ? 8051 ? 02/03 examples ;*f************************************************************************* ;* name: api_rd_eeprom_byte ;* dptr contain address to read. ;* acc contain the reading value ;* note: before execute this function, be sure the eeprom is not busy ;*************************************************************************** api_rd_eeprom_byte: ; save and clear ea mov eecon, #02h; map eeprom in xram space movx a, @dptr mov eecon, #00h; unmap eeprom ; restore ea ret ;*f************************************************************************* ;* name: api_ld_eeprom_cl ;* dptr contain address to load ;* acc contain value to load ;* note: in this example we load only 1 byte, but it is possible upto ;* 128 bytes. ;* before execute this function, be sure the eeprom is not busy ;*************************************************************************** api_ld_eeprom_cl: ; save and clear ea mov eecon, #02h ; map eeprom in xram space movx @dptr, a moveecon, #00h; unmap eeprom ; restore ea ret ;*f************************************************************************* ;* name: api_wr_eeprom ;* note: before execute this function, be sure the eeprom is not busy ;*************************************************************************** api_wr_eeprom: ; save and clear ea mov eecon, #050h mov eecon, #0a0h ; restore ea ret
32 T89C51AC2 4127d ? 8051 ? 02/03 registers table 20. eecon register eecon (s:0d2h) eeprom control register reset value = xxxx xx00b not bit addressable 76543210 eepl3 eepl2 eepl1 eepl0 - - eee eebusy bit number bit mnemonic description 7-4 eepl3-0 programming launch command bits write 5xh followed by axh to eepl to launch the programming. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2- reserved the value read from this bit is indeterminate. do not set this bit. 1eee enable eeprom space bit set to map the eeprom space during movx instructions (write in the column latches) clear to map the xram space during movx. 0eebusy programming busy flag set by hardware when programming is in progress. cleared by hardware when programming is done. can not be set or cleared by software.
33 T89C51AC2 4127d ? 8051 ? 02/03 program/code memory the T89C51AC2 implement 32 kb of on-chip program/code memory. figure 17 shows the partitioning of internal and external program/code memory spaces depending on the product. the flash memory increases eprom and rom functionality by in-circuit electrical era- sure and programming. thanks to the internal charge pump, the high voltage needed for programming or erasing flash cells is generated on-chip using the standard vdd volt- age. thus, the flash memory can be programmed using only one voltage and allows in- system-programming commonly known as isp. hardware programming mode is also available using specific programming tool. figure 17. program/code memory organization notes: 1. if the program executes exclusively from on-chip code memory (not from external memory), beware of executing code from the upper byte of on-chip memory (7fffh) and thereby disrupt i/o ports 0 and 2 due to external prefetch. fetching code con- stant from this location does not affect ports 0 and 2. 2. default factory programmed parts come with maximum hardware protection. execu- tion from external memory is not possible unless the hardware security byte is reprogrammed. see table 25. 0000h 32 kb 7fffh internal 0000h 7fffh ffffh 8000h flash 32 kb external memory 32 kb external memory ea = 0 ea = 1
34 T89C51AC2 4127d ? 8051 ? 02/03 external code memory access memory interface the external memory interface comprises the external bus (port 0 and port 2) as well as the bus control signals (psen#, and ale). figure 18 shows the structure of the external address bus. p0 carries address a7:0 while p2 carries address a15:8. data d7:0 is multiplexed with a7:0 on p0. table 18 describes the external memory interface signals. figure 18. external code memory interface structure external bus cycles this section describes the bus cycles the T89C51AC2 executes to fetch code (see figure 19) in the external program/code memory. external memory cycle takes 6 cpu clock periods. this is equivalent to 12 oscillator clock period in standard mode or 6 oscillator clock periods in x2 mode. for further infor- mation on x2 mode see section ? clock ? . for simplicity, the accompanying figure depicts the bus cycle waveforms in idealized form and do not provide precise timing information. for bus cycling parameters refer to the ? ac-dc parameters ? section. table 21. external code memory interface signals signal name type description alternate function a15:8 o address lines upper address lines for the external bus. p2.7:0 ad7:0 i/o address/data lines multiplexed lower address lines and data for the external memory. p0.7:0 ale o address latch enable ale signals indicates that valid address information are available on lines ad7:0. - psen# o program store enable output this signal is active low during external code fetch or external code read (movc instruction). - flash eprom T89C51AC2 p2 p0 ad7:0 a15:8 a7:0 a15:8 d7:0 a7:0 ale latch oe psen#
35 T89C51AC2 4127d ? 8051 ? 02/03 figure 19. external code fetch waveforms flash memory architecture T89C51AC2 features two on-chip flash memories:  flash memory fm0: containing 32 kb of program memory (user space) organized into 128 byte pages,  flash memory fm1: 2 kb for boot loader and application programming interfaces (api). the fm0 can be program by both parallel programming and serial in-system-program- ming (isp) whereas fm1 supports only parallel programming by programmers. the isp mode is detailed in the "in-system-programming" section. all read/write access operations on flash memory by user application are managed by a set of api described in the "in-system-programming" section. figure 20. flash memory architecture ale p0 p2 psen# pcl pch pch pcl d7:0 d7:0 pch d7:0 cpu clock 7fffh 32 kb flash memory fm0 0000h hardware security (1 byte) column latches (128 bytes) user space extra row (128 bytes) 2 kb flash memory fm1 boot space ffffh f800h fm1 mapped between f800h and ffffh when bit enboot is set in auxr1 register
36 T89C51AC2 4127d ? 8051 ? 02/03 fm0 memory architecture the flash memory is made up of 4 blocks (see figure 20):  the memory array (user space) 32 kb  the extra row  the hardware security bits  the column latch registers user space this space is composed of a 32 kb flash memory organized in 256 pages of 128 bytes. it contains the user ? s application code. extra row (xrow) this row is a part of fm0 and has a size of 128 bytes. the extra row may contain infor- mation for boot loader usage. hardware security byte the hardware security byte space is a part of fm0 and has a size of 1 byte. the 4 msb can be read/written by software, the 4 lsb can only be read by software and written by hardware in parallel mode. column latches the column latches, also part of fm0, have a size of full page (128 bytes). the column latches are the entrance buffers of the three previous memory locations (user array, xrow and hardware security byte). cross flash memory access description the fm0 memory can be program only from fm1. programming fm0 from fm0 or from external memory is impossible. the fm1 memory can be program only by parallel programming. the table 22 show all software flash access allowed. table 22. cross flash memory access code executing from action fm0 (user flash) fm1 (boot flash) fm0 (user flash) read ok - load column latch ok - write - - fm1 (boot flash) read ok ok load column latch ok - write ok - external memory ea = 0 read - - load column latch - - write - -
37 T89C51AC2 4127d ? 8051 ? 02/03 overview of fm0 operations the cpu interfaces to the flash memory through the fcon register and auxr1 register. these registers are used to:  map the memory spaces in the adressable space  launch the programming of the memory spaces  get the status of the flash memory (busy/not busy) mapping of the memory space by default, the user space is accessed by movc instruction for read only. the column latches space is made accessible by setting the fps bit in fcon register. writing is possible from 0000h to 7fffh, address bits 6 to 0 are used to select an address within a page while bits 14 to 7 are used to select the programming address of the page. setting fps bit takes precedence on the extram bit in auxr register. the other memory spaces (user, extra row, hardware security) are made accessible in the code segment by programming bits fmod0 and fmod1 in fcon register in accor- dance with table 23. a movc instruction is then used for reading these spaces. table 23. fm0 blocks select bits launching programming fpl3:0 bits in fcon register are used to secure the launch of programming. a specific sequence must be written in these bits to unlock the write protection and to launch the programming. this sequence is 5xh followed by axh. table 24 summarizes the memory spaces to program according to fmod1:0 bits. fmod1 fmod0 fm0 adressable space 0 0 user (0000h-7fffh) 0 1 extra row(ff80h-ffffh) 1 0 hardware security byte (0000h) 11reserved
38 T89C51AC2 4127d ? 8051 ? 02/03 table 24. programming spaces notes: 1. the sequence 5xh and axh must be executing without instructions between them otherwise the programming is aborted. 2. interrupts that may occur during programming time must be disabled to avoid any spurious exit of the programming mode. status of the flash memory the bit fbusy in fcon register is used to indicate the status of programming. fbusy is set when programming is in progress. selecting fm1 the bit enboot in auxr1 register is used to map fm1 from f800h to ffffh. loading the column latches any number of data from 1 byte to 128 bytes can be loaded in the column latches. this provides the capability to program the whole memory by byte, by page or by any number of bytes in a page. when programming is launched, an automatic erase of the locations loaded in the col- umn latches is first performed, then programming is effectively done. thus no page or block erase is needed and only the loaded data are programmed in the corresponding page. the following procedure is used to load the column latches and is summarized in figure 21:  save then disable interrupt and map the column latch space by setting fps bit.  load the dptr with the address to load.  load accumulator register with the data to load.  execute the movx @dptr, a instruction.  if needed loop the three last instructions until the page is completely loaded.  unmap the column latch and restore interrupt write to fcon operation fpl3:0 fps fmod1 fmod0 user 5 x 0 0 no action ax0 0 write the column latches in user space extra row 5 x 0 1 no action ax0 1 write the column latches in extra row space hardware security byte 5 x 1 0 no action a x 1 0 write the fuse bits space reserved 5 x 1 1 no action a x 1 1 no action
39 T89C51AC2 4127d ? 8051 ? 02/03 figure 21. column latches loading procedure note: the last page address used when loading the column latch is the one used to select the page programming address. programming the flash spaces user the following procedure is used to program the user space and is summarized in figure 22:  load up to one page of data in the column latches from address 0000h to 7fffh.  save then disable the interrupts.  launch the programming by writing the data sequence 50h followed by a0h in fcon register (only from fm1). the end of the programming indicated by the fbusy flag cleared.  restore the interrupts. extra row the following procedure is used to program the extra row space and is summarized in figure 22:  load data in the column latches from address ff80h to ffffh.  save then disable the interrupts.  launch the programming by writing the data sequence 52h followed by a2h in fcon register. this step of the procedure must be executed from fm1. the end of the programming indicated by the fbusy flag cleared. the end of the programming indicated by the fbusy flag cleared.  restore the interrupts. column latches loading data load dptr = address acc = data exec: movx @dptr, a last byte to load? column latches mapping fcon = 08h (fps=1) data memory mapping fcon = 00h (fps = 0) save and disable it ea = 0 restore it
40 T89C51AC2 4127d ? 8051 ? 02/03 figure 22. flash and extra row programming procedure hardware security byte the following procedure is used to program the hardware security byte space and is summarized in figure 23:  set fps and map hardware byte (fcon = 0x0c)  save and disable the interrupts.  load dptr at address 0000h.  load accumulator register with the data to load.  execute the movx @dptr, a instruction.  launch the programming by writing the data sequence 54h followed by a4h in fcon register. this step of the procedure must be executed from fm1. the end of the programming indicated by the fbusy flag cleared. the end of the programming indicated by the fbusy flag cleared.  restore the interrupts. flash spaces programming save and disable it ea = 0 launch programming fcon = 5xh fcon = axh end programming restore it column latches loading see figure 21 fbusy cleared? clear mode fcon = 00h
41 T89C51AC2 4127d ? 8051 ? 02/03 figure 23. hardware programming procedure reading the flash spaces user the following procedure is used to read the user space:  read one byte in accumulator by executing movc a,@a+dptr where a+dptr is the address of the code byte to read. note: fcon is supposed to be reset when not needed. extra row the following procedure is used to read the extra row space and is summarized in figure 24:  map the extra row space by writing 02h in fcon register.  read one byte in accumulator by executing movc a,@a+dptr with a = 0 and dptr = ff80h to ffffh.  clear fcon to unmap the extra row. hardware security byte the following procedure is used to read the hardware security space and is summarized in figure 24:  map the hardware security space by writing 04h in fcon register.  read the byte in accumulator by executing movc a,@a+dptr with a = 0 and dptr = 0000h.  clear fcon to unmap the hardware security byte. flash spaces programming save and disable it ea = 0 launch programming fcon = 54h fcon = a4h end programming restoreit fbusy cleared? clear mode fcon = 00h data load dptr = 00h acc = data exec: movx @dptr, a fcon = 0ch save and disable it ea = 0 end loading restore it
42 T89C51AC2 4127d ? 8051 ? 02/03 figure 24. reading procedure note: 1. aa = 10 for the hardware security byte. flash protection from parallel programming the three lock bits in hardware security byte (see "in-system-programming" section) are programmed according to table 25 provide different level of protection for the on- chip code and data located in fm0 and fm1. the only way to write these bits are the parallel mode. they are set by default to level 4 table 25. program lock bit program lock bits u: unprogrammed p: programmed warning: security level 2 and 3 should only be programmed after flash and core verification. preventing flash corruption see the ? power management ? section. flash spaces reading flash spaces mapping fcon = 0000aa0b (1) data read dptr = address acc = 0 exec: movc a, @a+dptr clear mode fcon = 00h program lock bits protection description security level lb0 lb1 lb2 1 uuu no program lock features enabled. movc instruction executed from external program memory returns non coded data. 2puu movc instructions executed from external program memory are barred to return code bytes from internal memory, ea is sampled and latched on reset, and further parallel programming of the flash is disabled. 3upu same as 2, also verify through parallel programming interface is disabled. 4uup same as 3, also external execution is disabled if code roll over beyond 7fffh
43 T89C51AC2 4127d ? 8051 ? 02/03 registers fcon registerfcon (s:d1h) flash control register reset value = 0000 0000b 76543210 fpl3 fpl2 fpl1 fpl0 fps fmod1 fmod0 fbusy bit number bit mnemonic description 7-4 fpl3:0 programming launch command bits write 5xh followed by axh to launch the programming according to fmod1:0 (see table 24) 3fps flash map program space set to map the column latch space in the data memory space. clear to re-map the data memory space. 2-1 fmod1:0 flash mode see table 23 or table 24. 0fbusy flash busy set by hardware when programming is in progress. clear by hardware when programming is done. can not be changed by software.
44 T89C51AC2 4127d ? 8051 ? 02/03 in-system programming (isp) with the implementation of the user space (fm0) and the boot space (fm1) in flash technology the T89C51AC2 allows the system engineer the development of applications with a very high level of flexibility. this flexibility is based on the possibility to alter the customer program at any stages of a product ? s life:  before mounting the chip on the pcb, fm0 flash can be programmed with the application code. fm1 is always preprogrammed by atmel with a bootloader (uart bootloader). (1)  once the chip is mounted on the pcb, it can be programmed by serial mode via the uart. note: 1. the user can also program his own bootloader in fm1. this in-system-programming (isp) allows code modification over the total lifetime of the product. besides the default boot loader atmel provide to the customer also all the needed appli- cation-programming-interfaces (api) which are needed for the isp. the api are located also in the boot memory. this allow the customer to have a full use of the 32 kb user memory. flash programming and erasure there are three methods of programming the flash memory:  the atmel bootloader located in fm1 is activated by the application. low level api routines (located in fm1) will be used to program fm0. the interface used for serial downloading to fm0 is the uart. api can be called also by the user ? s bootloader located in fm0 at [sbv]00h.  a further method exists in activating the atmel boot loader by hardware activation. see section ? hardware security byte ? .  the fm0 can be programmed also by the parallel mode using a programmer. figure 25. flash memory mapping f800h 7fffh 32 kb flash memory 2 kb iap bootloader fm0 fm1 custom boot loader [sbv]00h ffffh fm1 mapped between f800h and ffffh when api called 0000h
45 T89C51AC2 4127d ? 8051 ? 02/03 boot process software boot process example many algorithms can be used for the software boot process. below are descriptions of the different flags and bytes. boot loader jump bit (bljb): - this bit indicates if on reset the user wants to jump to this application at address @0000h on fm0 or execute the boot loader at address @f800h on fm1. - bljb = 0 (i.e. bootloader fm1 executed after a reset) is the default atmel factory pro- gramming. - to read or modify this bit, the apis are used. boot vector address (sbv): - this byte contains the msb of the user boot loader address in fm0. - the default value of sbv is ffh (no user boot loader in fm0). - to read or modify this byte, the apis are used. extra byte (eb) and boot status byte (bsb): - these bytes are reserved for customer use. - to read or modify these bytes, the apis are used. hardware boot process at the falling edge of reset, the bit enboot in auxr1 register is initialized with the value of boot loader jump bit (bljb). further at the falling edge of reset if the following conditions (called hardware condi- tion) are detected. the fcon register is initialized with the value 00h and the pc is initialized with f800h (fm1 lower byte = bootloader entry point). harware conditions:  psen low (1)  ea high,  ale high (or not connected). the hardware condition forces the bootloader to be executed, whatever bljb value is. then blbj will be checked. if no hardware condition is detected, the fcon register is initialized with the value f0h. then bljb value will be checked. conditions are:  if bit bljb = 1: user application in fm0 will be started at @0000h (standard reset).  if bit bljb = 0: boot loader will be started at @f800h in fm1. note: 1. as psen is an output port in normal operating mode (running user applications or bootloader applications) after reset it is recommended to release psen after the fall- ing edge of reset is signaled. the hardware conditions are sampled at reset signal falling edge, thus they can be released at any time when reset input is low.
46 T89C51AC2 4127d ? 8051 ? 02/03 figure 26. hardware boot process algorithm application programming interface several application program interface (api) calls are available for use by an application program to permit selective erasing and programming of flash pages. all calls are made by functions. all of these apis are described in detail in the following documents on the atmel web site.  datasheet bootloader uart T89C51AC2 xrow bytes table 26. xrow mapping reset hardware condition? bljb = = 0 ? bit enboot in auxr1 register is initialized with bljb inverted. hardware software enboot = 1 pc = f800h enboot = 1 pc = f800h fcon = 00h fcon = f0h boot loader in fm1 enboot = 0 pc = 0000h yes yes no no application in fm0 (example, if bljb=0, enboot is set (=1) during reset, thus the bootloader is executed after the reset) description default value address copy of the manufacturer code 58h 30h copy of the device id#1: family code d7h 31h copy of the device id#2: memories size and type f7h 60h copy of the device id#3: name and revision ffh 61h
47 T89C51AC2 4127d ? 8051 ? 02/03 hardware security byte table 27. hardware security byte default value after erasing chip: ffh notes: 1. only the 4 msb bits can be accessed by software. 2. the 4 lsb bits can only be accessed by parallel mode. 76543210 x2b bljb - - - lb2 lb1 lb0 bit number bit mnemonic description 7x2b x2 bit set this bit to start in standard mode. clear this bit to start in x2 mode. 6bljb boot loader jumpbit - 1: to start the user ? s application on next reset (@0000h) located in fm0, - 0: to start the boot loader(@f800h) located in fm1. 5-3 - reserved the value read from these bits are indeterminate. 2-0 lb2:0 lock bits
48 T89C51AC2 4127d ? 8051 ? 02/03 serial i/o port the T89C51AC2 i/o serial port is compatible with the i/o serial port in the 80c52. it provides both synchronous and asynchronous communication modes. it operates as a universal asynchronous receiver and transmitter (uart) in three full-duplex modes (modes 1, 2 and 3). asynchronous transmission and reception can occur simultaneously and at different baud rates serial i/o port includes the following enhancements:  framing error detection  automatic address recognition figure 27. serial i/o port block diagram framing error detection framing bit error detection is provided for the three asynchronous modes. to enable the framing bit error detection feature, set smod0 bit in pcon register. figure 28. framing error block diagram when this feature is enabled, the receiver checks each incoming data frame for a valid stop bit. an invalid stop bit may result from noise on the serial lines or from simultaneous transmission by two cpus. if a valid stop bit is not found, the framing error bit (fe) in scon register bit is set. the software may examine the fe bit after each reception to check for data errors. once set, only software or a reset clears the fe bit. subsequently received frames with valid stop bits cannot clear the fe bit. when the fe feature is enabled, ri rises on the stop bit instead of the last data bit (see figure 29. and figure 30.). write sbuf ri ti sbuf transmitter sbuf receiver ib bus mode 0 transmit receive shift register load sbuf read sbuf interrupt request serial port txd rxd ri ti rb8 tb8 ren sm2 sm1 sm0/fe idl pd gf0 gf1 pof - smod0 smod1 to uart framing error control sm0 to uart mode control set fe bit if stop bit is 0 (framing error)
49 T89C51AC2 4127d ? 8051 ? 02/03 figure 29. uart timing in mode 1 figure 30. uart timing in modes 2 and 3 automatic address recognition the automatic address recognition feature is enabled when the multiprocessor commu- nication feature is enabled (sm2 bit in scon register is set). implemented in the hardware, automatic address recognition enhances the multiproces- sor communication feature by allowing the serial port to examine the address of each incoming command frame. only when the serial port recognizes its own address will the receiver set the ri bit in the scon register to generate an interrupt. this ensures that the cpu is not interrupted by command frames addressed to other devices. if necessary, you can enable the automatic address recognition feature in mode 1. in this configuration, the stop bit takes the place of the ninth data bit. bit ri is set only when the received command frame address matches the device ? s address and is terminated by a valid stop bit. to support automatic address recognition, a device is identified by a given address and a broadcast address. note: the multiprocessor communication and automatic address recognition features cannot be enabled in mode 0 (i.e. setting sm2 bit in scon register in mode 0 has no effect). data byte ri smod0=x stop bit start bit rxd d7 d6 d5 d4 d3 d2 d1 d0 fe smod0=1 ri smod0=0 data byte ninth bit stop bit start bit rxd d8 d7 d6 d5 d4 d3 d2 d1 d0 ri smod0=1 fe smod0=1
50 T89C51AC2 4127d ? 8051 ? 02/03 given address each device has an individual address that is specified in the saddr register; the saden register is a mask byte that contains don ? t-care bits (defined by zeros) to form the device ? s given address. the don ? t-care bits provide the flexibility to address one or more slaves at a time. the following example illustrates how a given address is formed. to address a device by its individual address, the saden mask byte must be 1111 1111b . for example: saddr0101 0110b saden 1111 1100b given0101 01xxb here is an example of how to use given addresses to address different slaves: slave a:saddr1111 0001b saden 1111 1010b given1111 0x0xb slave b:saddr1111 0011b saden 1111 1001b given1111 0xx1b slave c:saddr1111 0010b saden 1111 1101b given1111 00x1b the saden byte is selected so that each slave may be addressed separately. for slave a, bit 0 (the lsb) is a don ? t-care bit; for slaves b and c, bit 0 is a 1. to com- municate with slave a only, the master must send an address where bit 0 is clear (e.g. 1111 0000b ). for slave a, bit 1 is a 0; for slaves b and c, bit 1 is a don ? t care bit. to communicate with slaves a and b, but not slave c, the master must send an address with bits 0 and 1 both set (e.g. 1111 0011b ). to communicate with slaves a, b and c, the master must send an address with bit 0 set, bit 1 clear, and bit 2 clear (e.g. 1111 0001b ). broadcast address a broadcast address is formed from the logical or of the saddr and saden registers with zeros defined as don ? t-care bits, e.g.: saddr 0101 0110b saden 1111 1100b saddr or saden1111 111xb the use of don ? t-care bits provides flexibility in defining the broadcast address, however in most applications, a broadcast address is ffh. the following is an example of using broadcast addresses: slave a:saddr1111 0001b saden 1111 1010b given1111 1x11b, slave b:saddr1111 0011b saden 1111 1001b given1111 1x11b, slave c:saddr=1111 0010b saden 1111 1101b given1111 1111b
51 T89C51AC2 4127d ? 8051 ? 02/03 for slaves a and b, bit 2 is a don ? t care bit; for slave c, bit 2 is set. to communicate with all of the slaves, the master must send an address ffh. to communicate with slaves a and b, but not slave c, the master can send and address fbh. registers table 28. scon register scon (s:98h) serial control register reset value = 0000 0000b bit addressable 76543210 fe/sm0 sm1 sm2 ren tb8 rb8 ti ri bit number bit mnemonic description 7fe framing error bit (smod0=1 ) clear to reset the error state, not cleared by a valid stop bit. set by hardware when an invalid stop bit is detected. sm0 serial port mode bit 0 (smod0=0) refer to sm1 for serial port mode selection. 6sm1 serial port mode bit 1 sm0 sm1 mode baud rate 0 0 shift register f xtal /12 (or f xtal /6 in mode x2) 0 1 8-bit uart variable 1 0 9-bit uart f xtal /64 or f xtal /32 1 1 9-bit uart variable 5sm2 serial port mode 2 bit/multiprocessor communication enable bit clear to disable multiprocessor communication feature. set to enable multiprocessor communication feature in mode 2 and 3. 4ren reception enable bit clear to disable serial reception. set to enable serial reception. 3tb8 transmitter bit 8/ninth bit to transmit in modes 2 and 3 clear to transmit a logic 0 in the 9th bit. set to transmit a logic 1 in the 9th bit. 2rb8 receiver bit 8/ninth bit received in modes 2 and 3 cleared by hardware if 9th bit received is a logic 0. set by hardware if 9th bit received is a logic 1. 1ti transmit interrupt flag clear to acknowledge interrupt. set by hardware at the end of the 8th bit time in mode 0 or at the beginning of the stop bit in the other modes. 0ri receive interrupt flag clear to acknowledge interrupt. set by hardware at the end of the 8th bit time in mode 0, see figure 29. and figure 30. in the other modes.
52 T89C51AC2 4127d ? 8051 ? 02/03 table 29. saden register saden (s:b9h) slave address mask register reset value = 0000 0000b not bit addressable table 30. saddr register saddr (s:a9h) slave address register reset value = 0000 0000b not bit addressable table 31. sbuf register sbuf (s:99h) serial data buffer reset value = 0000 0000b not bit addressable 76543210 ???????? bit number bit mnemonic description 7-0 mask data for slave individual address 76543210 ???????? bit number bit mnemonic description 7-0 slave individual address 76543210 ???????? bit number bit mnemonic description 7-0 data sent/received by serial i/o port
53 T89C51AC2 4127d ? 8051 ? 02/03 table 32. pcon register pcon (s:87h) power control register reset value = 00x1 0000b not bit addressable 76543210 smod1 smod0 ? pof gf1 gf0 pd idl bit number bit mnemonic description 7smod1 serial port mode bit 1 set to select double baud rate in mode 1, 2 or 3. 6smod0 serial port mode bit 0 clear to select sm0 bit in scon register. set to select fe bit in scon register. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4pof power-off flag clear to recognize next reset type. set by hardware when vcc rises from 0 to its nominal voltage. can also be set by software. 3gf1 general-purpose flag cleared by user for general-purpose usage. set by user for general-purpose usage. 2gf0 general-purpose flag cleared by user for general-purpose usage. set by user for general-purpose usage. 1pd power-down mode bit cleared by hardware when reset occurs. set to enter power-down mode. 0idl idle mode bit clear by hardware when interrupt or reset occurs. set to enter idle mode.
54 T89C51AC2 4127d ? 8051 ? 02/03 timers/counters the T89C51AC2 implements two general-purpose, 16-bit timers/counters. such are identified as timer 0 and timer 1, and can be independently configured to operate in a variety of modes as a timer or an event counter. when operating as a timer, the timer/counter runs for a programmed length of time, then issues an interrupt request. when operating as a counter, the timer/counter counts negative transitions on an external pin. after a preset number of counts, the counter issues an interrupt request. the various operating modes of each timer/counter are described in the following sections. timer/counter operations a basic operation is timer registers thx and tlx (x = 0, 1) connected in cascade to form a 16-bit timer. setting the run control bit (trx) in tcon register (see figure 33) turns the timer on by allowing the selected input to increment tlx. when tlx overflows it increments thx; when thx overflows it sets the timer overflow flag (tfx) in tcon register. setting the trx does not clear the thx and tlx timer registers. timer regis- ters can be accessed to obtain the current count or to enter preset values. they can be read at any time but trx bit must be cleared to preset their values, otherwise the behav- ior of the timer/counter is unpredictable. the c/tx# control bit selects timer operation or counter operation by selecting the divided-down peripheral clock or external pin tx as the source for the counted signal. trx bit must be cleared when changing the mode of operation, otherwise the behavior of the timer/counter is unpredictable. for timer operation (c/tx# = 0), the timer register counts the divided-down peripheral clock. the timer register is incremented once every peripheral cycle (6 peripheral clock periods). the timer clock rate is f per /6, i.e. f osc /12 in standard mode or f osc /6 in x2 mode. for counter operation (c/tx# = 1), the timer register counts the negative transitions on the tx external input pin. the external input is sampled every peripheral cycles. when the sample is high in one cycle and low in the next one, the counter is incremented. since it takes 2 cycles (12 peripheral clock periods) to recognize a negative transition, the maximum count rate is f per /12, i.e. f osc /24 in standard mode or f osc /12 in x2 mode. there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it should be held for at least one full peripheral cycle. timer 0 timer 0 functions as either a timer or event counter in four modes of operation. figure 31 to figure 34 show the logical configuration of each mode. timer 0 is controlled by the four lower bits of tmod register (see figure 34) and bits 0, 1, 4 and 5 of tcon register (see figure 33). tmod register selects the method of timer gating (gate0), timer or counter operation (t/c0#) and mode of operation (m10 and m00). tcon register provides timer 0 control functions: overflow flag (tf0), run control bit (tr0), interrupt flag (ie0) and interrupt type control bit (it0). for normal timer operation (gate0 = 0), setting tr0 allows tl0 to be incremented by the selected input. setting gate0 and tr0 allows external pin int0# to control timer operation. timer 0 overflow (count rolls over from all 1s to all 0s) sets tf0 flag generating an inter- rupt request. it is important to stop timer/counter before changing mode.
55 T89C51AC2 4127d ? 8051 ? 02/03 mode 0 (13-bit timer) mode 0 configures timer 0 as an 13-bit timer which is set up as an 8-bit timer (th0 register) with a modulo 32 prescaler implemented with the lower five bits of tl0 register (see figure 31). the upper three bits of tl0 register are indeterminate and should be ignored. prescaler overflow increments th0 register. figure 31. timer/counter x (x = 0 or 1) in mode 0 mode 1 (16-bit timer) mode 1 configures timer 0 as a 16-bit timer with th0 and tl0 registers connected in cascade (see figure 32). the selected input increments tl0 register. figure 32. timer/counter x (x = 0 or 1) in mode 1 ftx clock trx tcon reg tfx tcon reg 0 1 gatex tmod reg 6 overflow timer x interrupt request c/tx# tmod reg tlx (5 bits) thx (8 bits) intx# tx see the ? clock ? section trx tcon reg tfx tcon reg 0 1 gatex tmod reg overflow timer x interrupt request c/tx# tmod reg tlx (8 bits) thx (8 bits) intx# tx ftx clock 6 see the ? clock ? section
56 T89C51AC2 4127d ? 8051 ? 02/03 mode 2 (8-bit timer with auto- reload) mode 2 configures timer 0 as an 8-bit timer (tl0 register) that automatically reloads from th0 register (see figure 33). tl0 overflow sets tf0 flag in tcon register and reloads tl0 with the contents of th0, which is preset by software. when the interrupt request is serviced, hardware clears tf0. the reload leaves th0 unchanged. the next reload value may be changed at any time by writing it to th0 register. figure 33. timer/counter x (x = 0 or 1) in mode 2 mode 3 (two 8-bit timers) mode 3 configures timer 0 such that registers tl0 and th0 operate as separate 8-bit timers (see figure 34). this mode is provided for applications requiring an additional 8- bit timer or counter. tl0 uses the timer 0 control bits c/t0# and gate0 in tmod reg- ister, and tr0 and tf0 in tcon register in the normal manner. th0 is locked into a timer function (counting f per /6) and takes over use of the timer 1 interrupt (tf1) and run control (tr1) bits. thus, operation of timer 1 is restricted when timer 0 is in mode 3. figure 34. timer/counter 0 in mode 3: two 8-bit counters trx tcon reg tfx tcon reg 0 1 gatex tmod reg overflow timer x interrupt request c/tx# tmod reg tlx (8 bits) thx (8 bits) intx# tx ftx clock 6 see the ? clock ? section tr0 tcon.4 tf0 tcon.5 int0# 0 1 gate0 tmod.3 overflow timer 0 interrupt request c/t0# tmod.2 tl0 (8 bits) tr1 tcon.6 th0 (8 bits) tf1 tcon.7 overflow timer 1 interrupt request t0 ftx clock 6 ftx clock 6 see the ? clock ? section
57 T89C51AC2 4127d ? 8051 ? 02/03 timer 1 timer 1 is identical to timer 0 excepted for mode 3 which is a hold-count mode. the fol- lowing comments help to understand the differences:  timer 1 functions as either a timer or event counter in three modes of operation. figure 31 to figure 33 show the logical configuration for modes 0, 1, and 2. timer 1 ? s mode 3 is a hold-count mode.  timer 1 is controlled by the four high-order bits of tmod register (see figure 34) and bits 2, 3, 6 and 7 of tcon register (see figure 33). tmod register selects the method of timer gating (gate1), timer or counter operation (c/t1#) and mode of operation (m11 and m01). tcon register provides timer 1 control functions: overflow flag (tf1), run control bit (tr1), interrupt flag (ie1) and interrupt type control bit (it1).  timer 1 can serve as the baud rate generator for the serial port. mode 2 is best suited for this purpose.  for normal timer operation (gate1 = 0), setting tr1 allows tl1 to be incremented by the selected input. setting gate1 and tr1 allows external pin int1# to control timer operation.  timer 1 overflow (count rolls over from all 1s to all 0s) sets the tf1 flag generating an interrupt request.  when timer 0 is in mode 3, it uses timer 1 ? s overflow flag (tf1) and run control bit (tr1). for this situation, use timer 1 only for applications that do not require an interrupt (such as a baud rate generator for the serial port) and switch timer 1 in and out of mode 3 to turn it off and on.  it is important to stop timer/counter before changing mode. mode 0 (13-bit timer) mode 0 configures timer 1 as a 13-bit timer, which is set up as an 8-bit timer (th1 reg- ister) with a modulo-32 prescaler implemented with the lower 5 bits of the tl1 register (see figure 31). the upper 3 bits of tl1 register are ignored. prescaler overflow incre- ments th1 register. mode 1 (16-bit timer) mode 1 configures timer 1 as a 16-bit timer with th1 and tl1 registers connected in cascade (see figure 32). the selected input increments tl1 register. mode 2 (8-bit timer with auto- reload) mode 2 configures timer 1 as an 8-bit timer (tl1 register) with automatic reload from th1 register on overflow (see figure 33). tl1 overflow sets tf1 flag in tcon register and reloads tl1 with the contents of th1, which is preset by software. the reload leaves th1 unchanged. mode 3 (halt) placing timer 1 in mode 3 causes it to halt and hold its count. this can be used to halt timer 1 when tr1 run control bit is not available i.e. when timer 0 is in mode 3. interrupt each timer handles one interrupt source that is the timer overflow flag tf0 or tf1. this flag is set every time an overflow occurs. flags are cleared when vectoring to the timer interrupt routine. interrupts are enabled by setting etx bit in ien0 register. this assumes interrupts are globally enabled by setting ea bit in ien0 register.
58 T89C51AC2 4127d ? 8051 ? 02/03 figure 35. timer interrupt system tf0 tcon.5 et0 ien0.1 timer 0 interrupt request tf1 tcon.7 et1 ien0.3 timer 1 interrupt request
59 T89C51AC2 4127d ? 8051 ? 02/03 registers table 33. tcon register tcon (s:88h) timer/counter control register reset value = 0000 0000b 76543210 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 bit number bit mnemonic description 7tf1 timer 1 overflow flag cleared by hardware when processor vectors to interrupt routine. set by hardware on timer/counter overflow, when timer 1 register overflows. 6tr1 timer 1 run control bit clear to turn off timer/counter 1. set to turn on timer/counter 1. 5tf0 timer 0 overflow flag cleared by hardware when processor vectors to interrupt routine. set by hardware on timer/counter overflow, when timer 0 register overflows. 4tr0 timer 0 run control bit clear to turn off timer/counter 0. set to turn on timer/counter 0. 3ie1 interrupt 1 edge flag cleared by hardware when interrupt is processed if edge-triggered (see it1). set by hardware when external interrupt is detected on int1# pin. 2it1 interrupt 1 type control bit clear to select low level active (level triggered) for external interrupt 1 (int1#). set to select falling edge active (edge triggered) for external interrupt 1. 1ie0 interrupt 0 edge flag cleared by hardware when interrupt is processed if edge-triggered (see it0). set by hardware when external interrupt is detected on int0# pin. 0it0 interrupt 0 type control bit clear to select low level active (level triggered) for external interrupt 0 (int0#). set to select falling edge active (edge triggered) for external interrupt 0.
60 T89C51AC2 4127d ? 8051 ? 02/03 table 34. tmod register tmod (s:89h) timer/counter mode control register notes: 1. reloaded from th1 at overflow. 2. reloaded from th0 at overflow. reset value = 0000 0000b 76543210 gate1 c/t1# m11 m01 gate0 c/t0# m10 m00 bit number bit mnemonic description 7gate1 timer 1 gating control bit clear to enable timer 1 whenever tr1 bit is set. set to enable timer 1 only while int1# pin is high and tr1 bit is set. 6c/t1# timer 1 counter/timer select bit clear for timer operation: timer 1 counts the divided-down system clock. set for counter operation: timer 1 counts negative transitions on external pin t1. 5m11 timer 1 mode select bits m11 m01 operating mode 0 0 mode 0: 8-bit timer/counter (th1) with 5-bit prescaler (tl1). 0 1 mode 1: 16-bit timer/counter. 1 0 mode 2: 8-bit auto-reload timer/counter (tl1) (1) 1 1 mode 3: timer 1 halted. retains count 4m01 3gate0 timer 0 gating control bit clear to enable timer 0 whenever tr0 bit is set. set to enable timer/counter 0 only while int0# pin is high and tr0 bit is set. 2c/t0# timer 0 counter/timer select bit clear for timer operation: timer 0 counts the divided-down system clock. set for counter operation: timer 0 counts negative transitions on external pin t0. 1m10 timer 0 mode select bit m10 m00 operating mode 0 0 mode 0: 8-bit timer/counter (th0) with 5-bit prescaler (tl0). 0 1 mode 1: 16-bit timer/counter. 1 0 mode 2: 8-bit auto-reload timer/counter (tl0) (2) 1 1 mode 3: tl0 is an 8-bit timer/counter th0 is an 8-bit timer using timer 1 ? s tr0 and tf0 bits. 0 m00
61 T89C51AC2 4127d ? 8051 ? 02/03 table 35. th0 register th0 (s:8ch) timer 0 high byte register reset value = 0000 0000b table 36. tl0 register tl0 (s:8ah) timer 0 low byte register reset value = 0000 0000b table 37. th1 register th1 (s:8dh) timer 1 high byte register reset value = 0000 0000b 76543210 ???????? bit number bit mnemonic description 7:0 high byte of timer 0. 76543210 ???????? bit number bit mnemonic description 7:0 low byte of timer 0. 76543210 ???????? bit number bit mnemonic description 7:0 high byte of timer 1.
62 T89C51AC2 4127d ? 8051 ? 02/03 table 38. tl1 register tl1 (s:8bh) timer 1 low byte register reset value = 0000 0000b 76543210 ???????? bit number bit mnemonic description 7:0 low byte of timer 1.
63 T89C51AC2 4127d ? 8051 ? 02/03 timer 2 the T89C51AC2 timer 2 is compatible with timer 2 in the 80c52. it is a 16-bit timer/counter: the count is maintained by two eight-bit timer registers, th2 and tl2 that are cascade- connected. it is controlled by t2con register (see table ) and t2mod register (see table 41). timer 2 operation is similar to timer 0 and timer 1. c/t2 selects f t2 clock /6 (timer operation) or external pin t2 (counter operation) as timer clock. setting tr2 allows tl2 to be incremented by the selected input. timer 2 includes the following enhancements:  auto-reload mode (up or down counter)  programmable clock-output auto-reload mode the auto-reload mode configures timer 2 as a 16-bit timer or event counter with auto- matic reload. this feature is controlled by the dcen bit in t2mod register (see table 41). setting the dcen bit enables timer 2 to count up or down as shown in figure 36. in this mode the t2ex pin controls the counting direction. when t2ex is high, timer 2 counts up. timer overflow occurs at ffffh which sets the tf2 flag and generates an interrupt request. the overflow also causes the 16-bit value in rcap2h and rcap2l registers to be loaded into the timer registers th2 and tl2. when t2ex is low, timer 2 counts down. timer underflow occurs when the count in the timer registers th2 and tl2 equals the value stored in rcap2h and rcap2l registers. the underflow sets tf2 flag and reloads ffffh into the timer registers. the exf2 bit toggles when timer 2 overflow or underflow, depending on the direction of the count. exf2 does not generate an interrupt. this bit can be used to provide 17-bit resolution. figure 36. auto-reload mode up/down counter (down counting reload value) tf2 t2 exf2 th2 (8-bit) tl2 ( 8-bit) rcap2h (8-bit) rcap2l (8-bit) ffh (8-bit) ffh ( 8-bit) toggle (up counting reload value) timer 2 interrupt :6 t2conreg t2conreg t2ex: 1=up 2=down 0 1 ct/2 t2con.1 tr2 t2con.2 ft2 clock see section ? clock ?
64 T89C51AC2 4127d ? 8051 ? 02/03 programmable clock- output in clock-out mode, timer 2 operates as a 50%-duty-cycle, programmable clock genera- tor (see figure 37). the input clock increments tl2 at frequency f osc /2. the timer repeatedly counts to overflow from a loaded value. at overflow, the contents of rcap2h and rcap2l registers are loaded into th2 and tl2. in this mode, timer 2 overflows do not generate interrupts. the formula gives the clock-out frequency depending on the system oscillator frequency and the value in the rcap2h and rcap2l registers: for a 16 mhz system clock in x1 mode, timer 2 has a programmable frequency range of 61 hz (f osc /2 16) to 4 mhz (f osc /4). the generated clock signal is brought out to t2 pin (p1.0). timer 2 is programmed for the clock-out mode as follows:  set t2oe bit in t2mod register.  clear c/t2 bit in t2con register.  determine the 16-bit reload value from the formula and enter it in rcap2h/rcap2l registers.  enter a 16-bit initial value in timer registers th2/tl2. it can be the same as the reload value or different depending on the application.  to start the timer, set tr2 run control bit in t2con register. it is possible to use timer 2 as a baud rate generator and a clock generator simulta- neously. for this configuration, the baud rates and clock frequencies are not independent since both functions use the values in the rcap2h and rcap2l registers. figure 37. clock-out mode clock outfrequency ? ft 2 clock 4 65536 rcap 2 h ? rcap 2 l ? () ------------------------------------------------------------------------------------------- - = :2 exen2 exf2 overflow t2ex th2 (8-bit) tl2 (8-bit) timer 2 rcap2h (8-bit) rcap2l (8-bit) t2oe t2 t2con reg t2con reg t2mod reg 1 0 c/t2 t2con reg interrupt 0 1 ct/2 t2con.1 tr2 t2con.2 ft2 clock
65 T89C51AC2 4127d ? 8051 ? 02/03 registers table 39. t2con register t2con (s:c8h) timer 2 control register reset value = 0000 0000b bit addressable 76543210 tf2 exf2 rclk tclk exen2 tr2 c/t2# cp/rl2# bit number bit mnemonic description 7tf2 timer 2 overflow flag tf2 is not set if rclk=1 or tclk = 1. must be cleared by software. set by hardware on timer 2 overflow. 6exf2 timer 2 external flag set when a capture or a reload is caused by a negative transition on t2ex pin if exen2=1. set to cause the cpu to vector to timer 2 interrupt routine when timer 2 interrupt is enabled. must be cleared by software. 5 rclk receive clock bit clear to use timer 1 overflow as receive clock for serial port in mode 1 or 3. set to use timer 2 overflow as receive clock for serial port in mode 1 or 3. 4tclk transmit clock bit clear to use timer 1 overflow as transmit clock for serial port in mode 1 or 3. set to use timer 2 overflow as transmit clock for serial port in mode 1 or 3. 3exen2 timer 2 external enable bit clear to ignore events on t2ex pin for timer 2 operation. set to cause a capture or reload when a negative transition on t2ex pin is detected, if timer 2 is not used to clock the serial port. 2tr2 timer 2 run control bit clear to turn off timer 2. set to turn on timer 2. 1c/t2# timer/counter 2 select bit clear for timer operation (input from internal clock system: f osc ). set for counter operation (input from t2 input pin). 0 cp/rl2# timer 2 capture/reload bit if rclk=1 or tclk=1, cp/rl2# is ignored and timer is forced to auto-reload on timer 2 overflow. clear to auto-reload on timer 2 overflows or negative transitions on t2ex pin if exen2=1. set to capture on negative transitions on t2ex pin if exen2=1.
66 T89C51AC2 4127d ? 8051 ? 02/03 table 40. t2mod register t2mod (s:c9h) timer 2 mode control register reset value = xxxx xx00b not bit addressable table 41. th2 register th2 (s:cdh) timer 2 high byte register reset value = 0000 0000b not bit addressable 76543210 ------t2oedcen bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6- reserved the value read from this bit is indeterminate. do not set this bit. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2- reserved the value read from this bit is indeterminate. do not set this bit. 1t2oe timer 2 output enable bit clear to program p1.0/t2 as clock input or i/o port. set to program p1.0/t2 as clock output. 0 dcen down counter enable bit clear to disable timer 2 as up/down counter. set to enable timer 2 as up/down counter. 76543210 -------- bit number bit mnemonic description 7-0 high byte of timer 2.
67 T89C51AC2 4127d ? 8051 ? 02/03 table 42. tl2 register tl2 (s:cch) timer 2 low byte register reset value = 0000 0000b not bit addressable table 43. rcap2h register rcap2h (s:cbh) timer 2 reload/capture high byte register reset value = 0000 0000b not bit addressable table 44. rcap2l register rcap2l (s:ca h ) t imer 2 r e load/capture low byte register reset value = 0000 0000b not bit addressable 76543210 -------- bit number bit mnemonic description 7-0 low byte of timer 2. 76543210 -------- bit number bit mnemonic description 7-0 high byte of timer 2 reload/capture. 76543210 -------- bit number bit mnemonic description 7-0 low byte of timer 2 reload/capture.
68 T89C51AC2 4127d ? 8051 ? 02/03 watchdog timer T89C51AC2 contains a powerful programmable hardware watchdog timer (wdt) that automatically resets the chip if it software fails to reset the wdt before the selected time interval has elapsed. it permits large time-out ranking from 16ms to 2s @fosc = 12mhz in x1 mode. this wdt consists of a 14-bit counter plus a 7-bit programmable counter, a watchdog timer reset register (wdtrst) and a watchdog timer programming (wdtprg) regis- ter. when exiting reset, the wdt is -by default- disable. to enable the wdt, the user has to write the sequence 1eh and e1h into wdtrst register no instruction in between. when the watchdog timer is enabled, it will incre- ment every machine cycle while the oscillator is running and there is no way to disable the wdt except through reset (either hardware reset or wdt overflow reset). when wdt overflows, it will generate an output reset pulse at the rst pin. the reset pulse duration is 96xt osc , where t osc =1/f osc . to make the best use of the wdt, it should be serviced in those sections of code that will periodically be executed within the time required to prevent a wdt reset note: when the watchdog is enable it is impossible to change its period. figure 38. watchdog timer 6 ps cpu and peripheral clock fwd clock wdtprg reset decoder control wdtrst wr enable 14-bit counter 7-bit counter outputs reset - - - - - 2 1 0 fwd clock
69 T89C51AC2 4127d ? 8051 ? 02/03 watchdog programming the three lower bits (s0, s1, s2) located into wdtprg register permit to program the wdt duration. table 45. machine cycle count to compute wd time-out, the following formula is applied: note: svalue represents the decimal value of (s2 s1 s0) the following table outlines the time-out value for fosc xtal = 12 mhz in x1 mode table 46. time-out computation s2 s1 s0 machine cycle count 000 2 14 - 1 001 2 15 - 1 010 2 16 - 1 011 2 17 - 1 100 2 18 - 1 101 2 19 - 1 110 2 20 - 1 111 2 21 - 1 s2 s1 s0 fosc = 12 mhz fosc = 16 mhz fosc = 20 mhz 0 0 0 16.38 ms 12.28 ms 9.82 ms 0 0 1 32.77 ms 24.57 ms 19.66 ms 0 1 0 65.54 ms 49.14 ms 39.32 ms 0 1 1 131.07 ms 98.28 ms 78.64 ms 1 0 0 262.14 ms 196.56 ms 157.28 ms 1 0 1 524.29 ms 393.12 ms 314.56 ms 1 1 0 1.05 s 786.24 ms 629.12 ms 1 1 1 2.10 s 1.57 s 1.25 ms ftime out f wd 12 2 14 2 svalue () 1 ? () ------------------------------------------------------------------ - = ?
70 T89C51AC2 4127d ? 8051 ? 02/03 watchdog timer during power-down mode and idle in power-down mode the oscillator stops, which means the wdt also stops. while in power-down mode, the user does not need to service the wdt. there are 2 methods of exiting power-down mode: by a hardware reset or via a level activated external interrupt which is enabled prior to entering power-down mode. when power-down is exited with hardware reset, the watchdog is disabled. exiting power-down with an interrupt is sig- nificantly different. the interrupt shall be held low long enough for the oscillator to stabilize. when the interrupt is brought high, the interrupt is serviced. to prevent the wdt from resetting the device while the interrupt pin is held low, the wdt is not started until the interrupt is pulled high. it is suggested that the wdt be reset during the inter- rupt service for the interrupt used to exit power-down. to ensure that the wdt does not overflow within a few states of exiting powerdown, it is best to reset the wdt just before entering powerdown. in the idle mode, the oscillator continues to run. to prevent the wdt from resetting T89C51AC2 while in idle mode, the user should always set up a timer that will periodi- cally exit idle, service the wdt, and re-enter idle mode. register table 47. wdtprg register wdtprg (s:a7h) watchdog timer duration programming register reset value = xxxx x000b 76543210 ????? s2 s1 s0 bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6- reserved the value read from this bit is indeterminate. do not set this bit. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2s2 watchdog timer duration selection bit 2 work in conjunction with bit 1 and bit 0. 1s1 watchdog timer duration selection bit 1 work in conjunction with bit 2 and bit 0. 0s0 watchdog timer duration selection bit 0 work in conjunction with bit 1 and bit 2.
71 T89C51AC2 4127d ? 8051 ? 02/03 table 48. wdtrst register wdtrst (s:a6h write only) watchdog timer enable register reset value = 1111 1111b note: the wdrst register is used to reset/enable the wdt by writing 1eh then e1h in sequence without instruction between these two sequences. 76543210 ???????? bit number bit mnemonic description 7 - watchdog control value
72 T89C51AC2 4127d ? 8051 ? 02/03 programmable counter array (pca) the pca provides more timing capabilities with less cpu intervention than the standard timer/counters. its advantages include reduced software overhead and improved accu- racy. the pca consists of a dedicated timer/counter which serves as the time base for an array of five compare/capture modules. its clock input can be programmed to count any of the following signals:  pca clock frequency/6 (see ? clock ? section)  pca clock frequency/2  timer 0 overflow  external input on eci (p1.2) each compare/capture modules can be programmed in any one of the following modes:  rising and/or falling edge capture,  software timer,  high-speed output,  pulse width modulator. module 4 can also be programmed as a watchdog timer. see the "pca watchdog timer" section. when the compare/capture modules are programmed in capture mode, software timer, or high speed output mode, an interrupt can be generated when the module executes its function. all five modules plus the pca timer overflow share one interrupt vector. the pca timer/counter and compare/capture modules share port 1 for external i/os. these pins are listed below. if the port is not used for the pca, it can still be used for standard i/o. pca timer the pca timer is a common time base for all five modules (see figure 39). the timer count source is determined from the cps1 and cps0 bits in the cmod sfr (see table 8) and can be programmed to run at:  1/6 the pca clock frequency.  1/2 the pca clock frequency.  the timer 0 overflow.  the input on the eci pin (p1.2). pca component external i/o pin 16-bit counter p1.2/eci 16-bit module 0 p1.3/cex0 16-bit module 1 p1.4/cex1 16-bit module 2 p1.5/cex2 16-bit module 3 p1.6/cex3 16-bit module 4 p1.7/cex4
73 T89C51AC2 4127d ? 8051 ? 02/03 figure 39. pca timer/counter the cmod register includes three additional bits associated with the pca.  the cidl bit which allows the pca to stop during idle mode.  the wdte bit which enables or disables the watchdog function on module 4.  the ecf bit which when set causes an interrupt and the pca overflow flag cf in ccon register to be set when the pca timer overflows. the ccon register contains the run control bit for the pca and the flags for the pca timer and each module.  the cr bit must be set to run the pca. the pca is shut off by clearing this bit.  the cf bit is set when the pca counter overflows and an interrupt will be generated if the ecf bit in cmod register is set. the cf bit can only be cleared by software.  the ccf0:4 bits are the flags for the modules (ccf0 for module0...) and are set by hardware when either a match or a capture occurs. these flags also can be cleared by software. pca modules each one of the five compare/capture modules has six possible functions. it can perform:  16-bit capture, positive-edge triggered  16-bit capture, negative-edge triggered  16-bit capture, both positive and negative-edge triggered  16-bit software timer  16-bit high speed output  8-bit pulse width modulator. in addition module 4 can be used as a watchdog timer. cidl cps1 cps0 ecf it ch cl 16 bit up/down counter to pca modules fpca/6 fpca/2 t0 ovf p1.2 idle cmod 0xd9 wdte cf cr ccon 0xd8 ccf4 ccf3 ccf2 ccf1 ccf0 overflow
74 T89C51AC2 4127d ? 8051 ? 02/03 each module in the pca has a special function register associated with it (ccapm0 for module 0...). the ccapm0:4 registers contain the bits that control the mode that each module will operate in.  the eccf bit enables the ccf flag in the ccon register to generate an interrupt when a match or compare occurs in the associated module.  the pwm bit enables the pulse width modulation mode.  the tog bit when set causes the cex output associated with the module to toggle when there is a match between the pca counter and the module ? s capture/compare register.  the match bit mat when set will cause the ccfn bit in the ccon register to be set when there is a match between the pca counter and the module ? s capture/compare register.  the two bits capn and capp in ccapmn register determine the edge that a capture input will be active on. the capn bit enables the negative edge, and the capp bit enables the positive edge. if both bits are set both edges will be enabled.  the bit ecom in ccapm register when set enables the comparator function. pca interrupt figure 40. pca interrupt system pca capture mode to use one of the pca modules in capture mode either one or both of the ccapm bits capn and capp for that module must be set. the external cex input for the module (on port 1) is sampled for a transition. when a valid transition occurs the pca hardware loads the value of the pca counter registers (ch and cl) into the module ? s capture reg- isters (ccapnl and ccapnh). if the ccfn bit for the module in the ccon sfr and the eccfn bit in the ccapmn sfr are set then an interrupt will be generated. cf cr ccon ccf4 ccf3 ccf2 ccf1 ccf0 module 4 module 3 module 2 module 1 module 0 pca timer/counter eccfn ccapmn.0 to interrupt ea ien0.7 ec ien0.6 ecf cmod.0
75 T89C51AC2 4127d ? 8051 ? 02/03 figure 41. pca capture mode 16-bit software timer mode the pca modules can be used as software timers by setting both the ecom and mat bits in the modules ccapmn register. the pca timer will be compared to the module ? s capture registers and when a match occurs an interrupt will occur if the ccfn (ccon sfr) and the eccfn (ccapmn sfr) bits for the module are both set. figure 42. pca 16-bit software timer and high speed output mode cexn n = 0, 4 pca counter ch (8bits) cl (8bits) ccapnh ccapnl ccfn ccon pca interrupt request - 0cappn capnn 000 eccfn 7 ccapmn register (n = 0, 4) 0 ccapnl (8 bits) ccapnh (8 bits) - ecomn0 0 matn togn0 eccfn 70 ccapmn register (n = 0, 4) ch (8 bits) cl (8 bits) 16-bit comparator match enable ccfn ccon reg pca interrupt request cexn compare/capture module pca counter ? 0 ? ? 1 ? reset write to ccapnl write to ccapnh for software timer mode, set ecomn and matn. for high speed output mode, set ecomn, matn and togn. toggle
76 T89C51AC2 4127d ? 8051 ? 02/03 high speed output mode in this mode the cex output (on port 1) associated with the pca module will toggle each time a match occurs between the pca counter and the module ? s capture registers. to activate this mode the tog, mat, and ecom bits in the module ? s ccapmn sfr must be set. figure 43. pca high speed output mode pulse width modulator mode all the pca modules can be used as pwm outputs. the output frequency depends on the source for the pca timer. all the modules will have the same output frequency because they all share the pca timer. the duty cycle of each module is independently variable using the module ? s capture register ccapln. when the value of the pca cl sfr is less than the value in the module ? s ccapln sfr the output will be low, when it is equal to or greater than it, the output will be high. when cl overflows from ff to 00, ccapln is reloaded with the value in ccaphn. the allows the pwm to be updated with- out glitches. the pwm and ecom bits in the module ? s ccapmn register must be set to enable the pwm mode. ch cl ccapnh ccapnl ecomn ccapmn, n = 0 to 4 0xda to 0xde capnn matn togn pwmn eccfn cappn 16-bit comparator match cf cr ccon 0xd8 ccf4 ccf3 ccf2 ccf1 ccf0 pca it enable cexn pca counter/timer ? 1 ? ? 0 ? write to ccapnl reset write to ccapnh
77 T89C51AC2 4127d ? 8051 ? 02/03 figure 44. pca pwm mode pca watchdog timer an on-board watchdog timer is available with the pca to improve system reliability with- out increasing chip count. watchdog timers are useful for systems that are sensitive to noise, power glitches, or electrostatic discharge. module 4 is the only pca module that can be programmed as a watchdog. however, this module can still be used for other modes if the watchdog is not needed. the user pre-loads a 16-bit value in the compare registers. just like the other compare modes, this 16-bit value is compared to the pca timer value. if a match is allowed to occur, an internal reset will be generated. this will not cause the rst pin to be driven high. to hold off the reset, the user has three options:  periodically change the compare value so it will never match the pca timer,  periodically change the pca timer value so it will never match the compare values, or  disable the watchdog by clearing the wdte bit before a match occurs and then re- enable it. the first two options are more reliable because the watchdog timer is never disabled as in the third option. if the program counter ever goes astray, a match will eventually occur and cause an internal reset. if other pca modules are being used the second option not recommended either. remember, the pca timer is the time base for all modules; changing the time base for other modules would not be a good idea. thus, in most appli- cations the first solution is the best option. cl rolls over from ffh to 00h loads ccapnh contents into ccapnl ccapnl ccapnh 8-bit comparator cl (8 bits) ? 0 ? ? 1 ? cl < ccapnl cl > = ccapnl cex pwmn ccapmn.1 ecomn ccapmn.6
78 T89C51AC2 4127d ? 8051 ? 02/03 pca registers table 49. cmod register cmod (s:d9h) pca counter mode register reset value = 00xx x000b 76543210 cidl wdte - - - cps1 cps0 ecf bit number bit mnemonic description 7cidl pca counter idle control bit clear to let the pca run during idle mode. set to stop the pca when idle mode is invoked. 6wdte watchdog timer enable clear to disable watchdog timer function on pca module 4, set to enable it. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2cps1 ewc count pulse select bits cps1 cps0 clock source 0 0 internal clock, fpca/6 0 1 internal clock, fpca/2 1 0 timer 0 overflow 1 1 external clock at eci/p1.2 pin (max. rate = fpca/4) 1cps0 reserved the value read from this bit is indeterminate. do not set this bit. 0ecf enable pca counter overflow interrupt bit clear to disable cf bit in ccon register to generate an interrupt. set to enable cf bit in ccon register to generate an interrupt.
79 T89C51AC2 4127d ? 8051 ? 02/03 table 50. ccon register ccon (s:d8h) pca counter control register reset value = 00x0 0000b 76543210 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 bit number bit mnemonic description 7cf pca timer/counter overflow flag set by hardware when the pca timer/counter rolls over. this generates a pca interrupt request if the ecf bit in cmod register is set. must be cleared by software. 6cr pca timer/counter run control bit clear to turn the pca timer/counter off. set to turn the pca timer/counter on. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4 ccf4 pca module 4 compare/capture flag set by hardware when a match or capture occurs. this generates a pca interrupt request if the eccf 4 bit in ccapm 4 register is set. must be cleared by software. 3 ccf3 pca module 3 compare/capture flag set by hardware when a match or capture occurs. this generates a pca interrupt request if the eccf 3 bit in ccapm 3 register is set. must be cleared by software. 2 ccf2 pca module 2 compare/capture flag set by hardware when a match or capture occurs. this generates a pca interrupt request if the eccf 2 bit in ccapm 2 register is set. must be cleared by software. 1 ccf1 pca module 1 compare/capture flag set by hardware when a match or capture occurs. this generates a pca interrupt request if the eccf 1 bit in ccapm 1 register is set. must be cleared by software. 0 ccf0 pca module 0 compare/capture flag set by hardware when a match or capture occurs. this generates a pca interrupt request if the eccf 0 bit in ccapm 0 register is set. must be cleared by software.
80 T89C51AC2 4127d ? 8051 ? 02/03 table 51. ccapnh registers ccap0h (s:fah) ccap1h (s:fbh) ccap2h (s:fch) ccap3h (s:fdh) ccap4h (s:feh) pca high byte compare/capture module n register (n=0..4) reset value = 0000 0000b table 52. ccapnl registers ccap0l (s:eah) ccap1l (s:ebh) ccap2l (s:ech) ccap3l (s:edh) ccap4l (s:eeh) pca low byte compare/capture module n register (n=0..4) reset value = 0000 0000b 76543210 ccapnh 7 ccapnh 6 ccapnh 5 ccapnh 4 ccapnh 3 ccapnh 2 ccapnh 1 ccapnh 0 bit number bit mnemonic description 7:0 ccapnh 7:0 high byte of ewc-pca comparison or capture values 76543210 ccapnl 7 ccapnl 6 ccapnl 5 ccapnl 4 ccapnl 3 ccapnl 2 ccapnl 1 ccapnl 0 bit number bit mnemonic description 7:0 ccapnl 7:0 low byte of ewc-pca comparison or capture values
81 T89C51AC2 4127d ? 8051 ? 02/03 table 53. ccapmn registers ccapm0 (s:dah) ccapm1 (s:dbh) ccapm2 (s:dch) ccapm3 (s:ddh) ccapm4 (s:deh) pca compare/capture module n mode registers (n=0..4) reset value = x000 0000b 76543210 - ecomn cappn capnn matn togn pwmn eccfn bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6ecomn enable compare mode module x bit clear to disable the compare function. set to enable the compare function. the compare function is used to implement the software timer, the high-speed output, the pulse width modulator (pwm) and the watchdog timer (wdt). 5 cappn capture mode (positive) module x bit clear to disable the capture function triggered by a positive edge on cexx pin. set to enable the capture function triggered by a positive edge on cexx pin 4capnn capture mode (negative) module x bit clear to disable the capture function triggered by a negative edge on cexx pin. set to enable the capture function triggered by a negative edge on cexx pin. 3matn match module x bit set when a match of the pca counter with the compare/capture register sets ccfx bit in ccon register, flagging an interrupt. 2 togn toggle module x bit the toggle mode is configured by setting ecomx, matx and togx bits. set when a match of the pca counter with the compare/capture register toggles the cexx pin. 1pwmn pulse width modulation module x mode bit set to configure the module x as an 8-bit pulse width modulator with output waveform on cexx pin. 0eccfn enable ccfx interrupt bit clear to disable ccfx bit in ccon register to generate an interrupt request. set to enable ccfx bit in ccon register to generate an interrupt request.
82 T89C51AC2 4127d ? 8051 ? 02/03 table 54. ch register ch (s:f9h) pca counter register high value reset value = 0000 00000b table 55. cl register cl (s:e9h) pca counter register low value reset value = 0000 00000b 76543210 ch 7 ch 6 ch 5 ch 4 ch 3 ch 2 ch 1 ch 0 bit number bit mnemonic description 7:0 ch 7:0 high byte of timer/counter 76543210 cl 7cl 6cl 5cl 4cl 3cl 2cl 1cl 0 bit number bit mnemonic description 7:0 cl0 7:0 low byte of timer/counter
83 T89C51AC2 4127d ? 8051 ? 02/03 analog-to-digital converter (adc) this section describes the on-chip 10 bit analog-to-digital converter of the T89C51AC2. eight adc channels are available for sampling of the external sources an0 to an7. an analog multiplexer allows the single adc converter to select one from the 8 adc chan- nels as adc input voltage (adcin). adcin is converted by the 10-bit cascaded potentiometric adc. two modes of conversion are available: - standard conversion (8 bits). - precision conversion (10 bits). for the precision conversion, set bit psidle in adcon register and start conversion. the device is in a pseudo-idle mode, the cpu does not run but the peripherals are always running. this mode allows digital noise to be as low as possible, to ensure high precision conversion. for this mode it is necessary to work with end of conversion interrupt, which is the only way to wake the device up. if another interrupt occurs during the precision conversion, it will be served only after this conversion is completed. features  8 channels with multiplexed inputs  10-bit cascaded potentiometric adc  conversion time 16 micro-seconds (typ.)  zero error (offset) 2 lsb max  positive external reference voltage range (vref) 2.4 to 3.0volt (typ.)  adcin range 0 to 3volt  integral non-linearity typical 1 lsb, max. 2 lsb  differential non-linearity typical 0.5 lsb, max. 1 lsb  conversion complete flag or conversion complete interrupt  selectable adc clock adc port 1 i/o functions port 1 pins are general i/o that are shared with the adc channels. the channel select bit in adcf register define which adc channel/port1 pin will be used as adcin. the remaining adc channels/port1 pins can be used as general-purpose i/o or as the alter- nate function that is available. a conversion launched on a channel which are not selected on adcf register will not have any effect.
84 T89C51AC2 4127d ? 8051 ? 02/03 figure 45. adc description figure 46 shows the timing diagram of a complete conversion. for simplicity, the figure depicts the waveforms in idealized form and do not provide precise timing information. for adc characteristics and timing parameters refer to the section ? ac characteristics ? of the T89C51AC2 datasheet. figure 46. timing diagram note: tsetup min = 4 us tconv=11 clock adc = 1sample and hold + 10 bit conversion the user must ensure that 4 us minimum time between setting aden and the start of the first conversion. an0/p1.0 an1/p1.1 an2/p1.2 an3/p1.3 an4/p1.4 an5/p1.5 an6/p1.6 an7/p1.7 000 001 010 011 100 101 110 111 sch2 adcon.2 sch0 adcon.0 sch1 adcon.1 adc clock aden adcon.5 adsst adcon.3 adeoc adcon.4 adc interrupt request eadc ien1.1 control avss sample and hold addh varef r/2r dac vagnd 8 10 + - addl 2 sar adcin aden adsst adeoc t setup t conv clk
85 T89C51AC2 4127d ? 8051 ? 02/03 adc converter operation a start of single a/d conversion is triggered by setting bit adsst (adcon.3). after completion of the a/d conversion, the adsst bit is cleared by hardware. the end-of-conversion flag adeoc (adcon.4) is set when the value of conversion is available in addh and addl, it must be cleared by software. if the bit eadc (ien1.1) is set, an interrupt occur when flag adeoc is set (see figure 48). clear this flag for re- arming the interrupt. the bits sch0 to sch2 in adcon register are used for the analog input channel selection. (1) note: 1. always leave tsetup time before starting a conversion unless aden is permanently high. in this case one should wait tsetup only before the first conversion. table 56. selected analog input voltage conversion when the adcin is equals to varef the adc converts the signal to 3ffh (full scale). if the input voltage equals vagnd, the adc converts it to 000h. input voltage between varef and vagnd are a straight-line linear conversion. all other voltages will result in 3ffh if greater than varef and 000h if less than vagnd. note that adcin should not exceed varef absolute maximum range! (see section ? ac-dc ? ) varef varef should be connected to a low impedance point and must remain in the range specified in table 71. if the adc is not used, it is recommended to tie varef to vagnd. clock selection the adc clock is the same as cpu. the maximum clock frequency for adc is 700 khz. a prescaler is featured (adcclk) to generate the adc clock from the oscillator frequency. sch2 sch1 sch0 selected analog input 000an0 001an1 010an2 011an3 100an4 101an5 110an6 111an7
86 T89C51AC2 4127d ? 8051 ? 02/03 figure 47. a/d converter clock adc standby mode when the adc is not used, it is possible to set it in standby mode by clearing bit aden in adcon register. in this mode its power dissipation is reduced. it adc management an interrupt end-of-conversion will occurs when the bit adeoc is activated and the bit eadc is set. for re-arming the interrupt the bit adeoc must be cleared by software. figure 48. adc interrupt structure routines examples 1. configure p1.2 and p1.3 in adc channels // configure channel p1.2 and p1.3 for adc adcf = 0ch // enable the adc adcon = 20h 2. start a standard conversion // the variable "channel" contains the channel to convert // the variable "value_converted" is an unsigned int // clear the field sch[2:0] adcon and = f8h // select channel adcon | = channel // start conversion in standard mode adcon | = 08h // wait flag end of conversion while((adcon and 01h)! = 01h) // clear the end of conversion flag adcon and = efh // read the value value_converted = (addh << 2)+(addl) prescaler adclk a/d converter adc clock cpu clock cpu core clock symbol 2 adeoc adcon.2 eadc ien1.1 adci
87 T89C51AC2 4127d ? 8051 ? 02/03 3. start a precision conversion (need interrupt adc) // the variable "channel" contains the channel to convert // enable adc eadc = 1 // clear the field sch[2:0] adcon and = f8h // select the channel adcon | = channel // start conversion in precision mode adcon | = 48h note: to enable the adc interrupt: ea = 1
88 T89C51AC2 4127d ? 8051 ? 02/03 registers table 57. adcf register adcf (s:f6h) adc configuration reset value = 0000 0000b table 58. adcon register adcon (s:f3h) adc control register reset value = x000 0000b 76543210 ch 7 ch 6 ch 5 ch 4 ch 3 ch 2 ch 1 ch 0 bit number bit mnemonic description 7-0 ch 0:7 channel configuration set to use p1.x as adc input. clear to use p1.x as standart i/o port. 76543210 - psidle aden adeoc adsst sch2 sch1 sch0 bit number bit mnemonic description 7- 6 psidle pseudo idle mode (best precision) set to put in idle mode during conversion clear to convert without idle mode. 5aden enable/standby mode set to enable adc clear for standby mode (power dissipation 1 uw). 4adeoc end of conversion set by hardware when adc result is ready to be read. this flag can generate an interrupt. must be cleared by software. 3 adsst start and status set to start an a/d conversion. cleared by hardware after completion of the conversion 2-0 sch2:0 selection of channel to convert see table 56
89 T89C51AC2 4127d ? 8051 ? 02/03 table 59. adclk register adclk (s:f2h) adc clock prescaler reset value = xxx0 0000b table 60. addh register addh (s:f5h read only) adc data high byte register reset value = 00h table 61. addl register addl (s:f4h read only) adc data low byte register reset value = 00h 76543210 - - - prs 4prs 3prs 2prs 1prs 0 bit number bit mnemonic description 7-5 - reserved the value read from these bits are indeterminate. do not set these bits. 4-0 prs4:0 clock prescaler f adc = fcpu clock/ (4 (or 2 in x2 mode)* (prs +1)) 76543210 adat 9 adat 8 adat 7 adat 6 adat 5 adat 4 adat 3 adat 2 bit number bit mnemonic description 7-0 adat9:2 adc result bits 9-2 76543210 ------adat 1adat 0 bit number bit mnemonic description 7-2 - reserved the value read from these bits are indeterminate. do not set these bits. 1-0 adat1:0 adc result bits 1-0
90 T89C51AC2 4127d ? 8051 ? 02/03 interrupt system introduction the controller has a total of 8 interrupt vectors: two external interrupts (int0 and int1 ), three timer interrupts (timers 0, 1 and 2), a serial port interrupt, a pca, a timer overrun interrupt and an adc. these interrupts are shown below. figure 49. interrupt control system ex0 ien0.0 00 01 10 11 external interrupt 0 int0# ex1 ien0.2 external interrupt 1 int1# et0 ien0.1 timer 0 ec ien0.6 pca et1 ien0.3 timer 1 es ien0.4 uart eadc ien1.1 a to d converter interrupt enable lowest priority interrupts highest priority enable 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11 priority interrupts ain1:0 timer 2 00 01 10 11 et2 ien0.5 txd rxd cex0:5
91 T89C51AC2 4127d ? 8051 ? 02/03 each of the interrupt sources can be individually enabled or disabled by setting or clear- ing a bit in the interrupt enable register. this register also contains a global disable bit which must be cleared to disable all the interrupts at the same time. each interrupt source can also be individually programmed to one of four priority levels by setting or clearing a bit in the interrupt priority registers. the table below shows the bit values and priority levels associated with each combination. table 62. priority level bit values a low-priority interrupt can be interrupted by a high priority interrupt but not by another low-priority interrupt. a high-priority interrupt cannot be interrupted by any other interrupt source. if two interrupt requests of different priority levels are received simultaneously, the request of the higher priority level is serviced. if interrupt requests of the same priority level are received simultaneously, an internal polling sequence determines which request is serviced. thus within each priority level there is a second priority structure determined by the polling sequence, see table 63. table 63. interrupt priority within level iph.x ipl.x interrupt level priority 0 0 0 (lowest) 011 102 1 1 3 (highest) interrupt name interrupt address vector priority number external interrupt (int0) 0003h 1 timer 0 (tf0) 000bh 2 external interrupt (int1) 0013h 3 timer 1 (tf1) 001bh 4 pca (cf or ccfn) 0033h 5 uart (ri or ti) 0023h 6 timer 2 (tf2) 002bh 7 adc (adci) 0043h 9
92 T89C51AC2 4127d ? 8051 ? 02/03 registers table 64. ien0 register ien0 (s:a8h) interrupt enable register reset value = 0000 0000b bit addressable 76543210 ea ec et2 es et1 ex1 et0 ex0 bit number bit mnemonic description 7ea enable all interrupt bit clear to disable all interrupts. set to enable all interrupts. if ea=1, each interrupt source is individually enabled or disabled by setting or clearing its interrupt enable bit. 6ec pca interrupt enable clear to disable the pca interrupt. set to enable the pca interrupt. 5et2 timer 2 overflow interrupt enable bit clear to disable timer 2 overflow interrupt. set to enable timer 2 overflow interrupt. 4es serial port enable bit clear to disable serial port interrupt. set to enable serial port interrupt. 3et1 timer 1 overflow interrupt enable bit clear to disable timer 1 overflow interrupt. set to enable timer 1 overflow interrupt. 2ex1 external interrupt 1 enable bit clear to disable external interrupt 1. set to enable external interrupt 1. 1et0 timer 0 overflow interrupt enable bit clear to disable timer 0 overflow interrupt. set to enable timer 0 overflow interrupt. 0ex0 external interrupt 0 enable bit clear to disable external interrupt 0. set to enable external interrupt 0.
93 T89C51AC2 4127d ? 8051 ? 02/03 table 65. ien1 register ien1 (s:e8h) interrupt enable register reset value = xxxx xx00b bit addressable 76543210 ------eadc- bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6- reserved the value read from this bit is indeterminate. do not set this bit. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2- reserved the value read from this bit is indeterminate. do not set this bit. 1 eadc adc interrupt enable bit clear to disable the adc interrupt. set to enable the adc interrupt. 0- reserved the value read from this bit is indeterminate. do not set this bit.
94 T89C51AC2 4127d ? 8051 ? 02/03 table 66. ipl0 register ipl0 (s:b8h) interrupt enable register reset value = x000 0000b bit addressable 76543210 - ppc pt2 ps pt1 px1 pt0 px0 bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6 ppc pca interrupt priority bit refer to ppch for priority level 5pt2 timer 2 overflow interrupt priority bit refer to pt2h for priority level. 4ps serial port priority bit refer to psh for priority level. 3pt1 timer 1 overflow interrupt priority bit refer to pt1h for priority level. 2px1 external interrupt 1 priority bit refer to px1h for priority level. 1pt0 timer 0 overflow interrupt priority bit refer to pt0h for priority level. 0px0 external interrupt 0 priority bit refer to px0h for priority level.
95 T89C51AC2 4127d ? 8051 ? 02/03 table 67. ipl1 register ipl1 (s:f8h) interrupt priority low register 1 reset value = xxxx xx0xb bit addressable 76543210 ------p adcl - bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6- reserved the value read from this bit is indeterminate. do not set this bit. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2- reserved the value read from this bit is indeterminate. do not set this bit. 1padcl adc interrupt priority level less significant bit refer to pspih for priority level. 0- reserved the value read from this bit is indeterminate. do not set this bit.
96 T89C51AC2 4127d ? 8051 ? 02/03 table 68. iph0 register iph0 (b7h) interrupt high priority register reset value = x000 0000b 76543210 - ppch pt2h psh pt1h px1h pt0h px0h bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6 ppch pca interrupt priority level most significant bit ppch ppc priority level 0 0 lowest 01 1 0 1 1 highest priority 5pt2h timer 2 overflow interrupt high priority bit pt2h pt2 priority level 0 0 lowest 0 1 10 1 1 highest 4 psh serial port high priority bit psh ps priority level 0 0 lowest 0 1 1 0 1 1 highest 3pt1h timer 1 overflow interrupt high priority bit pt1h pt1 priority level 0 0 lowest 0 1 1 0 1 1 highest 2px1h external interrupt 1 high priority bit px1h px1 priority level 0 0 lowest 0 1 1 0 1 1 highest 1pt0h timer 0 overflow interrupt high priority bit pt0h pt0 priority level 0 0 lowest 0 1 1 0 1 1 highest 0px0h external interrupt 0 high priority bit px0h px0 priority level 0 0 lowest 0 1 1 0 1 1 highest
97 T89C51AC2 4127d ? 8051 ? 02/03 table 69. iph1 register iph1 (s:f7h) interrupt high priority register 1 reset value = xxxx x000b 76543210 ------p adch - bit number bit mnemonic description 7- reserved the value read from this bit is indeterminate. do not set this bit. 6- reserved the value read from this bit is indeterminate. do not set this bit. 5- reserved the value read from this bit is indeterminate. do not set this bit. 4- reserved the value read from this bit is indeterminate. do not set this bit. 3- reserved the value read from this bit is indeterminate. do not set this bit. 2- reserved the value read from this bit is indeterminate. do not set this bit. 1 padch adc interrupt priority level most significant bit padch padcl priority level 0 0 lowest 0 1 1 0 1 1 highest 0- reserved the value read from this bit is indeterminate. do not set this bit.
98 T89C51AC2 4127d ? 8051 ? 02/03 electrical characteristics absolute maximum ratings* dc parameters for standard voltage t a = -40 c to +85 c; v ss = 0v; v cc = 3v to 5.5v; f = 0 to 40 mhz ambiant temperature under bias: i = industrial ....................................................... -40 c to 85 c storage temperature .................................... -65 c to + 150 c voltage on v cc from v ss ......................................-0.5v to + 6v voltage on any pin from v ss ..................... -0.5v to v cc + 0.2v power dissipation ............................................................... 1w table 70. dc parameters in standard voltage symbol parameter min typ (5) max unit test conditions v il input low voltage -0.5 0.2vcc - 0.1 v v ih input high voltage except xtal1, rst 0.2 v cc + 0.9 v cc + 0.5 v v ih1 input high voltage, xtal1, rst 0.7 v cc v cc + 0.5 v v ol output low voltage, ports 1, 2, 3 and 4 (6) 0.3 0.45 1.0 v v v i ol = 100 a (4) i ol = 1.6 ma (4) i ol = 3.5 ma (4) v ol1 output low voltage, port 0, ale, psen (6) 0.3 0.45 1.0 v v v i ol = 200 a (4) i ol = 3.2 ma (4) i ol = 7.0 ma (4) v oh output high voltage, ports 1, 2, 3, 4 and 5 v cc - 0.3 v cc - 0.7 v cc - 1.5 v v v i oh = -10 a i oh = -30 a i oh = -60 a v oh1 output high voltage, port 0, ale, psen v cc - 0.3 v cc - 0.7 v cc - 1.5 v v v i oh = -200 a i oh = -3.2 ma i oh = -7.0 ma r rst rst pulldown resistor 20 40 200 k ? i il logical 0 input current ports 1, 2, 3 and 4 -50 a vin = 0.45v i li input leakage current 10 a 0.45v < vin < v cc i tl logical 1 to 0 transition current, ports 1, 2, 3 and 4 -650 a vin = 2.0v c io capacitance of i/o buffer 10 pf fc = 1 mhz t a = 25 c i pd power-down current 160 350 a3v < v cc < 5.5v (3) i cc power supply current i ccop = 0.7 freq (mhz) + 3 ma icc_flash_write (7) =0.4 freq (mhz) + 20 ma i ccidle = 0.6 freq (mhz) + 2 ma 3v < v cc < 5.5v (1)(2) *notice: stresses at or above those listed under ? absolute max- imum ratings ? may cause permanent damage to the device. this is a stress rating only and functional oper- ation of the device at these or any other conditions above those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions may affect device reliability. the power dissipation is based on the maximum allow- able die temperature and the thermal resistance of the package.
99 T89C51AC2 4127d ? 8051 ? 02/03 notes: 1. operating i cc is measured with all output pins disconnected; xtal1 driven with t clch , t chcl = 5 ns (see figure 53.), v il = v ss + 0.5v, v ih = v cc - 0.5v; xtal2 n.c.; ea = rst = port 0 = v cc . i cc would be slightly higher if a crystal oscillator used (see figure 50.). 2. idle i cc is measured with all output pins disconnected; xtal1 driven with t clch , t chcl = 5 ns, v il = v ss + 0.5v, v ih = v cc - 0.5v; xtal2 n.c; port 0 = v cc ; ea = rst = v ss (see figure 51.). 3. power-down i cc is measured with all output pins disconnected; ea = v cc , port 0 = v cc ; xtal2 nc.; rst = v ss (see figure 52.). in addition, the wdt must be inactive and the pof flag must be set. 4. capacitance loading on ports 0 and 2 may cause spurious noise pulses to be super- imposed on the v ol s of ale and ports 1 and 3. the noise is due to external bus capacitance discharging into the port 0 and port 2 pins when these pins make 1 to 0 transitions during bus operation. in the worst cases (capacitive loading 100pf), the noise pulse on the ale line may exceed 0.45v with maxi v ol peak 0.6v. a schmitt trigger use is not necessary. 5. typicals are based on a limited number of samples and are not guaranteed. the val- ues listed are at room temperature. 6. under steady state (non-transient) conditions, i ol must be externally limited as fol- lows: maximum i ol per port pin: 10 ma maximum i ol per 8-bit port: port 0: 26 ma ports 1, 2 and 3: 15 ma maximum total i ol for all output pins: 71 ma if i ol exceeds the test condition, v ol may exceed the related specification. pins are not guaranteed to sink current greater than the listed test conditions. 7. icc_flash_write operating current while a flash block write is on going. figure 50. i cc test condition, active mode ea v cc v cc i cc (nc) clock signal v cc all other pins are disconnected. rst xtal2 xtal1 v ss v cc p0
100 T89C51AC2 4127d ? 8051 ? 02/03 figure 51. i cc test condition, idle mode figure 52. i cc test condition, power-down mode figure 53. clock signal waveform for i cc tests in active and idle modes rst ea xtal2 xtal1 v ss v cc v cc i cc (nc) p0 v cc all other pins are disconnected. clock signal rst ea xtal2 xtal1 v ss v cc v cc i cc (nc) p0 v cc all other pins are disconnected. v cc -0.5v 0.45v 0.7v cc 0.2v cc -0.1 t clch t chcl t clch = t chcl = 5ns.
101 T89C51AC2 4127d ? 8051 ? 02/03 dc parameters for a/d converter notes: 1. typicals are based on a limited number of samples and are not guaranteed. 2. with adc enabled. ac parameters explanation of the ac symbols each timing symbol has 5 characters. the first character is always a ? t ? (stands for time). the other characters, depending on their positions, stand for the name of a signal or the logical status of that signal. the following is a list of all the characters and what they stand for. example: t avll = time for address valid to ale low. t llpl = time for ale low to psen low. t a = -40 c to +85 c; v ss = 0v; v cc = 5v 10%; f = 0 to 40 mhz. t a = -40 c to +85 c; v ss = 0v; v cc = 5v 10%. (load capacitance for port 0, ale and psen = 60 pf; load capacitance for all other outputs = 60 pf.) table 72, table 75 and table 78 give the description of each ac symbols. table 73, table 77 and table 79 give for each range the ac parameter. table 74, table 77 and table 80 give the frequency derating formula of the ac parame- ter for each speed range description. to calculate each ac symbols: take the x value and use this value in the formula. example: t lliv and 20 mhz, standard clock. x = 30 ns t = 50 ns t cciv = 4t - x = 170 ns table 71. dc parameters for ad converter in precision conversion symbol parameter min typ (1) max unit test conditions avin analog input voltage vss- 0.2 vref + 0.2 v rref (2) resistance between vref and vss 12 16 24 k ? vref reference voltage 2.40 3.00 v cai analog input capacitance 60 pf during sampling inl integral non linearity 1 2 lsb dnl differential non linearity 0.5 1 lsb oe offset error -2 2 lsb
102 T89C51AC2 4127d ? 8051 ? 02/03 external program memory characteristics table 72. symbol description table 73. ac parameters for a fix clock (f = 40 mhz) symbol parameter t oscillator clock period t lhll ale pulse width t av ll address valid to ale t llax address hold after ale t lliv ale to valid instruction in t llpl ale to psen t plph psen pulse width t pliv psen to valid instruction in t pxix input instruction hold after psen t pxiz input instruction float after psen t aviv address to valid instruction in t plaz psen low to address float symbol min max units t25 ns t lhll 40 ns t avll 10 ns t llax 10 ns t lliv 70 ns t llpl 15 ns t plph 55 ns t pliv 35 ns t pxix 0ns t pxiz 18 ns t aviv 85 ns t plaz 10 ns
103 T89C51AC2 4127d ? 8051 ? 02/03 table 74. ac parameters for a variable clock external program memory read cycle symbol type standard clock x2 clock x parameter units t lhll min 2 t - x t - x 10 ns t avll min t - x 0.5 t - x 15 ns t llax min t - x 0.5 t - x 15 ns t lliv max 4 t - x 2 t - x 30 ns t llpl min t - x 0.5 t - x 10 ns t plph min 3 t - x 1.5 t - x 20 ns t pliv max 3 t - x 1.5 t - x 40 ns t pxix min x x 0 ns t pxiz max t - x 0.5 t - x 7 ns t aviv max 5 t - x 2.5 t - x 40 ns t plaz max x x 10 ns t pliv tplaz ale psen port 0 port 2 a0-a7 a0-a7 instr in instr in instr in address or sfr-p2 address a8-a15 address a8-a15 12 t clcl t av iv t lhll t avll t lliv t llpl t plph t pxav t pxix t pxiz t llax
104 T89C51AC2 4127d ? 8051 ? 02/03 external data memory characteristics table 75. symbol description table 76. ac parameters for a variable clock (f = 40 mhz) symbol parameter t rlrh rd pulse width t wlwh wr pulse width t rldv rd to valid data in t rhdx data hold after rd t rhdz data float after rd t lldv ale to valid data in t avdv address to valid data in t llwl ale to wr or rd t avw l address to wr or rd t qvwx data valid to wr transition t qvwh data set-up to wr high t whqx data hold after wr t rlaz rd low to address float t whlh rd or wr high to ale high symbol min max units t rlrh 130 ns t wlwh 130 ns t rldv 100 ns t rhdx 0ns t rhdz 30 ns t lldv 160 ns t avdv 165 ns t llwl 50 100 ns t avwl 75 ns t qvwx 10 ns t qvwh 160 ns t whqx 15 ns t rlaz 0ns t whlh 10 40 ns
105 T89C51AC2 4127d ? 8051 ? 02/03 table 77. ac parameters for a variable clock symbol type standard clock x2 clock x parameter units t rlrh min 6 t - x 3 t - x 20 ns t wlwh min 6 t - x 3 t - x 20 ns t rldv max 5 t - x 2.5 t - x 25 ns t rhdx min x x 0 ns t rhdz max 2 t - x t - x 20 ns t lldv max 8 t - x 4t -x 40 ns t avdv max 9 t - x 4.5 t - x 60 ns t llwl min 3 t - x 1.5 t - x 25 ns t llwl max 3 t + x 1.5 t + x 25 ns t avwl min 4 t - x 2 t - x 25 ns t qvwx min t - x 0.5 t - x 15 ns t qvwh min 7 t - x 3.5 t - x 25 ns t whqx min t - x 0.5 t - x 10 ns t rlaz max x x 0 ns t whlh min t - x 0.5 t - x 15 ns t whlh max t + x 0.5 t + x 15 ns
106 T89C51AC2 4127d ? 8051 ? 02/03 external data memory write cycle external data memory read cycle serial port timing ? shift register mode table 78. symbol description (f = 40 mhz) t qvwh t llax ale psen wr port 0 port 2 a0-a7 data out address or sfr-p2 t avw l t llwl t qvwx address a8-a15 or sfr p2 t whqx t whlh t wlwh ale psen rd port 0 port 2 a0-a7 data in address or sfr-p2 t avwl t llwl t rlaz address a8-a15 or sfr p2 t rhdz t whlh t rlrh t lldv t rhdx t llax t avdv symbol parameter t xlxl serial port clock cycle time t qvhx output data set-up to clock rising edge t xhqx output data hold after clock rising edge t xhdx input data hold after clock rising edge t xhdv clock rising edge to input data valid
107 T89C51AC2 4127d ? 8051 ? 02/03 table 79. ac parameters for a fix clock (f = 40 mhz) table 80. ac parameters for a variable clock shift register timing waveforms external clock drive characteristics (xtal1) table 81. ac parameters symbol min max units t xlxl 300 ns t qvhx 200 ns t xhqx 30 ns t xhdx 0ns t xhdv 117 ns symbol type standard clock x2 clock x parameter for -m range units t xlxl min 12 t 6 t ns t qvhx min 10 t - x 5 t - x 50 ns t xhqx min 2 t - x t - x 20 ns t xhdx min x x 0 ns t xhdv max 10 t - x 5 t- x 133 ns valid valid valid valid valid valid input data valid 0123456 8 7 ale clock output data write to sbuf clear ri t xlxl t qvxh t xhqx t xhdv t xhdx set ti set ri instruction 01234567 valid symbol parameter min max units t clcl oscillator period 25 ns t chcx high time 5 ns t clcx low time 5 ns t clch rise time 5 ns t chcl fall time 5 ns t chcx /t clcx cyclic ratio in x2 mode 40 60 %
108 T89C51AC2 4127d ? 8051 ? 02/03 external clock drive waveforms ac testing input/output waveforms ac inputs during testing are driven at v cc - 0.5 for a logic ? 1 ? and 0.45v for a logic ? 0 ? . timing measurement are made at v ih min for a logic ? 1 ? and v il max for a logic ? 0 ? . float waveforms for timing purposes as port pin is no longer floating when a 100 mv change from load voltage occurs and begins to float when a 100 mv change from the loaded v oh /v ol level occurs. i ol /i oh 20 ma. v cc -0.5v 0.45v 0.7v cc 0.2v cc -0.1 t chcl t clcx t clcl t clch t chcx input/output 0.2 v cc + 0.9 0.2 v cc - 0.1 v cc -0.5v 0.45v float v oh - 0.1 v v ol + 0.1 v v load v load + 0.1 v v load - 0.1 v
109 T89C51AC2 4127d ? 8051 ? 02/03 clock waveforms valid in normal clock mode. in x2 mode xtal2 must be changed to xtal2/2. this diagram indicates when signals are clocked internally. the time it takes the signals to propagate to the pins, however, ranges from 25 to 125 ns. this propagation delay is dependent on variables such as temperature and pin loading. propaga- tion also varies from output to output and component. typically though (t a =25 c fully loaded) rd and wr propagation delays are approximately 50ns. the other signals are typically 85 ns. propagation delays are incorporated in the ac specifications. data pcl out data pcl out data pcl out sampled sampled sampled state4 state5 state6 state1 state2 state3 state4 state5 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 p1 p2 float float float these signals are not activated during the execution of a movx instruction indicates address transitions external program memory fetch float data sampled dpl or rt out indicates dph or p2 sfr to pch transition pcl out (if program memory is external) pcl out (even if program memory is internal) pcl out (if program memory is external old data new data p0 pins sampled p1, p2, p3 pins sampled p1, p2, p3 pins sampled p0 pins sampled rxd sampled internal clock xtal2 ale psen p0 p2 (ext) read cycle write cycle rd p0 p2 wr port operation mov port src mov dest p0 mov dest port (p1. p2. p3) (includes into. int1. to t1) serial port shift clock txd (mode 0) data out dpl or rt out indicates dph or p2 sfr to pch transition p0 p2 rxd sampled
110 T89C51AC2 4127d ? 8051 ? 02/03 flash memory table 82. timing symbol definitions table 83. memory ac timing vdd = 5v 10%, ta = -40 to +85 c figure 54. flash memory ? isp waveforms figure 55. flash memory ? internal busy waveforms table 84. ac parameters for a/d conversion signals conditions s (hardware condition) psen#,ea l low rrst vvalid b fbusy flag x no longer valid symbol parameter min typ max unit t svrl input psen# valid to rst edge 50 ns t rlsx input psen# hold after rst edge 50 ns t bhbl flash internal busy (programming) time 10 ms symbol parameter min typ max unit t setup 4s adc clock frequency 700 khz rst t svrl psen#1 t rlsx fbusy bit t bhbl
111 T89C51AC2 4127d ? 8051 ? 02/03 ordering information table 85. possible order entries part number supply voltage temperature range max frequency package packing T89C51AC2-rltim 3v to 5.5v + 10% industrial 40 mhz vqfp44 tray T89C51AC2-slsim 3v to 5.5v + 10% industrial 40 mhz plcc44 stick
112 T89C51AC2 4127d ? 8051 ? 02/03 package drawings vqfp44
113 T89C51AC2 4127d ? 8051 ? 02/03 plcc44
i preliminary/confidential T89C51AC2 4127d ? 8051 ? 02/03 table of contents features ................................................................................................. 1 description ............................................................................................ 2 block diagram ....................................................................................... 2 pin configuration .................................................................................. 3 i/o configurations................................................................................................. 6 port 1, port 3 and port 4 ....................................................................................... 6 port 0 and port 2................................................................................................... 6 read-modify-write instructions ............................................................................ 7 quasi-bidirectional port operation ....................................................................... 8 sfr mapping ....................................................................................... 10 clock .................................................................................................... 14 description.......................................................................................................... 14 register 17 power management ............................................................................ 18 reset pin ............................................................................................................ 18 at power-up (cold reset)................................................................................... 18 reset recommendation to prevent flash corruption ........................................ 19 idle mode ............................................................................................................ 19 power-down mode.............................................................................................. 20 registers............................................................................................................. 22 data memory ....................................................................................... 23 internal space 24 external space ................................................................................................... 25 dual data pointer 27 registers............................................................................................................. 28 eeprom data memory ....................................................................... 30 write data in the column latches ...................................................................... 30 programming ...................................................................................................... 30 read data........................................................................................................... 30 examples ............................................................................................................ 31 registers............................................................................................................. 32 program/code memory ...................................................................... 33 external code memory access 34 flash memory architecture................................................................................. 35 overview of fm0 operations .............................................................................. 37
ii T89C51AC2 4127d ? 8051 ? 02/03 registers............................................................................................................. 43 in-system programming (isp) ........................................................... 44 flash programming and erasure........................................................................ 44 boot process ...................................................................................................... 45 application programming interface..................................................................... 46 xrow bytes....................................................................................................... 46 hardware security byte ...................................................................................... 47 serial i/o port ...................................................................................... 48 framing error detection .................................................................................... 48 automatic address recognition.......................................................................... 49 given address 50 broadcast address ............................................................................................. 50 registers............................................................................................................. 51 timers/counters ................................................................................. 54 timer/counter operations .................................................................................. 54 timer 0................................................................................................................ 54 timer 1 57 interrupt .............................................................................................................. 57 registers............................................................................................................. 59 timer 2 ................................................................................................. 63 auto-reload mode............................................................................................. 63 programmable clock-output .............................................................................. 64 registers............................................................................................................. 65 watchdog timer .................................................................................. 68 watchdog programming 69 watchdog timer during power-down mode and idle 70 programmable counter array (pca) ................................................ 72 pca timer .......................................................................................................... 72 pca modules...................................................................................................... 73 pca interrupt ...................................................................................................... 74 pca capture mode............................................................................................. 74 16-bit software timer mode ............................................................................... 75 high speed output mode 76 pulse width modulator mode.............................................................................. 76 pca watchdog timer ......................................................................................... 77 pca registers 78 analog-to-digital converter (adc) .................................................... 83 features.............................................................................................................. 83 adc port 1 i/o functions ................................................................................... 83
iii preliminary/confidential T89C51AC2 4127d ? 8051 ? 02/03 adc converter operation................................................................................... 85 voltage conversion ............................................................................................ 85 varef................................................................................................................ 85 clock selection ................................................................................................... 85 adc standby mode ............................................................................................ 86 it adc management .......................................................................................... 86 routines examples............................................................................................. 86 registers 88 interrupt system ................................................................................. 90 introduction ......................................................................................................... 90 registers............................................................................................................. 92 electrical characteristics ................................................................... 98 absolute maximum ratings* ...............................................................................98 dc parameters for standard voltage .................................................................98 dc parameters for a/d converter ....................................................................101 ac parameters .................................................................................................101 ordering information ........................................................................ 111 package drawings 112 vqfp44 ............................................................................................................ 112 plcc44 ............................................................................................................ 113
printed on recycled paper. atmel ? is a registered trademark of atmel. other terms and product names may be the trademarks of others. ? atmel corporation 2003. atmel corporation makes no warranty for the use of its products, other than those expressly contained in the company ? s standard warranty which is detailed in atmel ? s terms and conditions located on the company ? s web site. the company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without n otice, and does not make any commitment to update the information contained herein. no licenses to patents or other intellectual property of at mel are granted by the company in connection with the sale of atmel products, expressly or by implication. atmel ? s products are not authorized for use as critical components in life support devices or systems. atmel headquarters atmel operations corporate headquarters 2325 orchard parkway san jose, ca 95131 tel 1(408) 441-0311 fax 1(408) 487-2600 europe atmel sarl route des arsenaux 41 case postale 80 ch-1705 fribourg switzerland tel (41) 26-426-5555 fax (41) 26-426-5500 asia room 1219 chinachem golden plaza 77 mody road tsimhatsui east kowloon hong kong tel (852) 2721-9778 fax (852) 2722-1369 japan 9f, tonetsu shinkawa bldg. 1-24-8 shinkawa chuo-ku, tokyo 104-0033 japan tel (81) 3-3523-3551 fax (81) 3-3523-7581 memory 2325 orchard parkway san jose, ca 95131 tel 1(408) 441-0311 fax 1(408) 436-4314 microcontrollers 2325 orchard parkway san jose, ca 95131 tel 1(408) 441-0311 fax 1(408) 436-4314 la chantrerie bp 70602 44306 nantes cedex 3, france tel (33) 2-40-18-18-18 fax (33) 2-40-18-19-60 asic/assp/smart cards zone industrielle 13106 rousset cedex, france tel (33) 4-42-53-60-00 fax (33) 4-42-53-60-01 1150 east cheyenne mtn. blvd. colorado springs, co 80906 tel 1(719) 576-3300 fax 1(719) 540-1759 scottish enterprise technology park maxwell building east kilbride g75 0qr, scotland tel (44) 1355-803-000 fax (44) 1355-242-743 rf/automotive theresienstrasse 2 postfach 3535 74025 heilbronn, germany tel (49) 71-31-67-0 fax (49) 71-31-67-2340 1150 east cheyenne mtn. blvd. colorado springs, co 80906 tel 1(719) 576-3300 fax 1(719) 540-1759 biometrics/imaging/hi-rel mpu/ high speed converters/rf datacom avenue de rochepleine bp 123 38521 saint-egreve cedex, france tel (33) 4-76-58-30-00 fax (33) 4-76-58-34-80 e-mail literature@atmel.com web site http://www.atmel.com 4127d ? 8051 ? 02/03 /xm


▲Up To Search▲   

 
Price & Availability of T89C51AC2

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X